diff --git a/src/global.c b/src/global.c index a19b0db2..967de080 100644 --- a/src/global.c +++ b/src/global.c @@ -259,6 +259,13 @@ char *rcfile_with_errors = NULL; /* The first nanorc file, if any, that produced warnings. */ #endif +bool spotlighted = FALSE; + /* Whether any text is spotlighted. */ +size_t light_from_col = 0; + /* Where the spotlighted text starts. */ +size_t light_to_col = 0; + /* Where the spotlighted text ends. */ + /* Return the number of entries in the shortcut list for a given menu. */ size_t length_of_list(int menu) { diff --git a/src/proto.h b/src/proto.h index b0227253..0460572c 100644 --- a/src/proto.h +++ b/src/proto.h @@ -175,6 +175,10 @@ extern char *statedir; extern char *rcfile_with_errors; #endif +extern bool spotlighted; +extern size_t light_from_col; +extern size_t light_to_col; + typedef void (*functionptrtype)(void); /* Most functions in browser.c. */ diff --git a/src/search.c b/src/search.c index 18f8880a..a8b14291 100644 --- a/src/search.c +++ b/src/search.c @@ -575,19 +575,18 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only, numreplaced = 0; if (!replaceall) { - size_t from_col = xplustabs(); - size_t to_col = strnlenpt(openfile->current->data, + spotlighted = TRUE; + light_from_col = xplustabs(); + light_to_col = strnlenpt(openfile->current->data, openfile->current_x + match_len); /* Refresh the edit window, scrolling it if necessary. */ edit_refresh(); - spotlight(TRUE, from_col, to_col); - /* TRANSLATORS: This is a prompt. */ i = do_yesno_prompt(TRUE, _("Replace this instance?")); - spotlight(FALSE, from_col, to_col); + spotlighted = FALSE; if (i == -1) /* The replacing was cancelled. */ break; diff --git a/src/text.c b/src/text.c index 67710f0b..3f1da94f 100644 --- a/src/text.c +++ b/src/text.c @@ -2584,21 +2584,20 @@ bool fix_spello(const char *word) proceed = TRUE; napms(2800); } else if (result == 1) { - size_t from_col = xplustabs(); - size_t to_col = from_col + strlenpt(word); + spotlighted = TRUE; + light_from_col = xplustabs(); + light_to_col = light_from_col + strlenpt(word); #ifndef NANO_TINY filestruct *saved_mark = openfile->mark; openfile->mark = NULL; #endif edit_refresh(); - spotlight(TRUE, from_col, to_col); - /* Let the user supply a correctly spelled alternative. */ proceed = (do_prompt(FALSE, FALSE, MSPELL, word, NULL, edit_refresh, _("Edit a replacement")) != -1); - spotlight(FALSE, from_col, to_col); + spotlighted = FALSE; #ifndef NANO_TINY openfile->mark = saved_mark; diff --git a/src/winio.c b/src/winio.c index 10331e28..2660681c 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2780,6 +2780,9 @@ int update_line(filestruct *fileptr, size_t index) if (strlenpt(fileptr->data) > from_col + editwincols) mvwaddch(edit, row, COLS - 1, '$'); + if (spotlighted && !inhelp) + spotlight(TRUE, light_from_col, light_to_col); + return 1; } @@ -2846,6 +2849,9 @@ int update_softwrapped_line(filestruct *fileptr) from_col = to_col; } + if (spotlighted && !inhelp) + spotlight(TRUE, light_from_col, light_to_col); + return (row - starting_row); } #endif