search: automatically drop the spotlighting after a few moments

Even though I know that spotlighted text is not selected, I still
regularly think for a fleeting instant that the spotlighted text
can be cut with a ^K.  Mitigate this by dropping the spotlighting
after 1.5 seconds (or 0.8 seconds when using --quick).
master
Benno Schulenberg 2021-05-31 10:40:46 +02:00
parent 092c62ccb8
commit 3f340836a6
2 changed files with 11 additions and 9 deletions

View File

@ -2524,11 +2524,6 @@ int main(int argc, char **argv)
} else if (LINES > 1 || lastmessage == VACUUM)
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;

View File

@ -193,8 +193,9 @@ void read_keys_from(WINDOW *win)
curs_set(1);
#ifndef NANO_TINY
if (currmenu == MMAIN && (ISSET(MINIBAR) || LINES == 1) && lastmessage > HUSH &&
lastmessage != INFO && lastmessage < ALERT) {
if (currmenu == MMAIN && (spotlighted || ((ISSET(MINIBAR) || LINES == 1) &&
lastmessage > HUSH &&
lastmessage != INFO && lastmessage < ALERT))) {
timed = TRUE;
halfdelay(ISSET(QUICK_BLANK) ? 8 : 15);
disable_kb_interrupt();
@ -216,11 +217,13 @@ void read_keys_from(WINDOW *win)
raw();
if (input == ERR) {
if (LINES == 1) {
if (spotlighted || LINES == 1) {
lastmessage = VACUUM;
spotlighted = FALSE;
edit_refresh();
curs_set(1);
} else
}
if (ISSET(MINIBAR) && LINES > 1)
minibar();
as_an_at = TRUE;
place_the_cursor();
@ -245,6 +248,10 @@ void read_keys_from(WINDOW *win)
key_buffer_len = 1;
#ifndef NANO_TINY
/* Cancel the highlighting of a search match, if there still is one. */
refresh_needed |= spotlighted;
spotlighted = FALSE;
/* If we got a SIGWINCH, get out as the win argument is no longer valid. */
if (input == KEY_WINCH)
return;