commit 3f340836a6fdb5b7305add137d8614b23347c9a5
parent 092c62ccb8ee66fbdeeb28656f13c9c298731300
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 31 May 2021 10:40:46 +0200
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).
Diffstat:
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/nano.c b/src/nano.c
@@ -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;
diff --git a/src/winio.c b/src/winio.c
@@ -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;