Author Topic: Search & Replace preview...  (Read 266 times)

jporkkahtc

  • Senior Community Member
  • Posts: 1684
  • Hero Points: 161
  • Text
Search & Replace preview...
« on: July 09, 2018, 02:55:55 pm »
During interactive S&R, Slick previews the change by showing the proposed change in red text below.

This overlay can mix with existing text and be visually confusing. See the attached images for an example - where the overlay is on top of the line below in a confusing way.

I'd  like Slick to push the text below down to avoid the overlay entirely - something like what Diff does with "imaginary lines".

Alternately, expand the red-text box - make it wider than necessary to give it some margins on the left and right.
« Last Edit: July 09, 2018, 02:58:26 pm by jporkkahtc »

jporkkahtc

  • Senior Community Member
  • Posts: 1684
  • Hero Points: 161
  • Text
Re: Search & Replace preview...
« Reply #1 on: July 09, 2018, 03:08:19 pm »
Cool ... I implemented the 2nd option, expanding the replace preview.
Its crude, but mostly works (with a solid 90 seconds of testing  ;D).

In "_showReplaceToolTip"

Code: [Select]
   // Ideally, instead of hard-coding "3", this would insert
   // spaces enough to reach the 1st display column (handling horizontal scroll position).
   // "3" works in the usual case, but it can bump up against the left edge of the display
   // and cause the tooltip to be positioned incorrectly.
   int x = p_cursor_x - p_font_width * 3;
   int y = p_cursor_y + p_font_height;
   _map_xy(p_window_id, 0, x, y);
   _str new_text = "   " expand_tabs(get_replace_text(replace_string)) "   ";