From 37717baeedb228163c915063deecabcfa7c2c157 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 25 Jan 2021 16:35:07 +0100 Subject: [PATCH] search: just highlight the found occurrence, instead of marking it Requested-by: Peter Passchier --- src/help.c | 2 +- src/nano.c | 5 +++++ src/search.c | 8 ++++---- src/winio.c | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/help.c b/src/help.c index b497f548..0b6b235e 100644 --- a/src/help.c +++ b/src/help.c @@ -461,7 +461,7 @@ void show_help(void) didfind = 0; #ifndef NANO_TINY - openfile->mark = NULL; + spotlighted = FALSE; hide_cursor = FALSE; if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) { diff --git a/src/nano.c b/src/nano.c index 6c5eda5e..1df6736c 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2540,6 +2540,11 @@ int main(int argc, char **argv) } else edit_refresh(); +#ifndef NANO_TINY + /* Let the next keystroke cancel the highlighting of a search match. */ + refresh_needed = spotlighted; + spotlighted = FALSE; +#endif errno = 0; focusing = TRUE; diff --git a/src/search.c b/src/search.c index 0238cc85..bb81cf21 100644 --- a/src/search.c +++ b/src/search.c @@ -324,12 +324,12 @@ int findnextstr(const char *needle, bool whole_word_only, int modus, #ifndef NANO_TINY if (modus == JUSTFIND && ISSET(MARK_MATCH) && (!openfile->mark || openfile->softmark)) { - openfile->mark = line; - openfile->mark_x = found_x + found_len; - openfile->softmark = TRUE; + spotlighted = TRUE; + light_from_col = xplustabs(); + light_to_col = wideness(line->data, found_x + found_len); if (!ISSET(SHOW_CURSOR)) hide_cursor = TRUE; - shift_held = TRUE; + refresh_needed = TRUE; } #endif diff --git a/src/winio.c b/src/winio.c index ff5e5a3a..16b0405d 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2854,7 +2854,7 @@ int update_line(linestruct *line, size_t index) wattroff(edit, hilite_attribute); } - if (spotlighted && line == openfile->current && !inhelp) + if (spotlighted && line == openfile->current) spotlight(light_from_col, light_to_col); return 1; @@ -2915,7 +2915,7 @@ int update_softwrapped_line(linestruct *line) from_col = to_col; } - if (spotlighted && line == openfile->current && !inhelp) + if (spotlighted && line == openfile->current) spotlight_softwrapped(light_from_col, light_to_col); return (row - starting_row);