display: do spotlighting as part of drawing the screen

When something is spotlighted, it should survive a refresh of
the screen and an excursion to a help text, so the spotlight
should get painted whenever the edit window is drawn.

This fully fixes https://savannah.gnu.org/bugs/?54721.
master
David Lawrence Ramsey 2018-09-29 11:14:43 -05:00 committed by Benno Schulenberg
parent 7ea6d6bbda
commit c2e4f77594
5 changed files with 25 additions and 10 deletions

View File

@ -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)
{

View File

@ -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. */

View File

@ -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;

View File

@ -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;

View File

@ -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