[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] search: automatically drop spotlighting after a few moments
From: |
Benno Schulenberg |
Subject: |
[PATCH] search: automatically drop spotlighting after a few moments |
Date: |
Mon, 31 May 2021 11:02:06 +0200 |
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).
---
src/nano.c | 5 -----
src/winio.c | 15 +++++++++++----
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/nano.c b/src/nano.c
index abc49174..fe226849 100644
--- 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
index 57e4043a..e679ed0d 100644
--- 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;
--
2.29.3
- [PATCH] search: automatically drop spotlighting after a few moments,
Benno Schulenberg <=