nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 37717baeedb228163c915063deecabcfa7c2c157
parent ade2fafbd3068056908a5168c447eee59af44465
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Mon, 25 Jan 2021 16:35:07 +0100

search: just highlight the found occurrence, instead of marking it

Requested-by: Peter Passchier <peter@passchier.net>

Diffstat:
Msrc/help.c | 2+-
Msrc/nano.c | 5+++++
Msrc/search.c | 8++++----
Msrc/winio.c | 4++--
4 files changed, 12 insertions(+), 7 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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);