[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/4] search: suppress the cursor when highlighting a match
From: |
Benno Schulenberg |
Subject: |
[PATCH 2/4] search: suppress the cursor when highlighting a match |
Date: |
Sun, 20 Dec 2020 17:04:30 +0100 |
Having a block cursor present when highlighting a match...
does not look nice. So... hide the cursor until the next
keystroke, unless --showcursor or 'set showcursor' is used.
---
src/global.c | 2 ++
src/help.c | 3 +++
src/nano.c | 2 ++
src/prototypes.h | 1 +
src/search.c | 2 ++
src/winio.c | 2 +-
6 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/global.c b/src/global.c
index 8b2bb7ac..ef231d25 100644
--- a/src/global.c
+++ b/src/global.c
@@ -79,6 +79,8 @@ linestruct *pletion_line = NULL;
bool also_the_last = FALSE;
/* Whether indenting/commenting should include the last line of
* the marked region. */
+bool hide_cursor = FALSE;
+ /* Whether to suppress the cursor when highlighting a search
match. */
char *answer = NULL;
/* The answer string used by the status-bar prompt. */
diff --git a/src/help.c b/src/help.c
index c5ea2827..6ff1ae34 100644
--- a/src/help.c
+++ b/src/help.c
@@ -457,6 +457,9 @@ void show_help(void)
/* Show the cursor when we searched and found something. */
kbinput = get_kbinput(edit, didfind == 1 || ISSET(SHOW_CURSOR));
+
+ openfile->mark = NULL;
+ hide_cursor = FALSE;
didfind = 0;
#ifndef NANO_TINY
diff --git a/src/nano.c b/src/nano.c
index 1f349ca7..24a8998c 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -1502,6 +1502,8 @@ void process_a_keystroke(void)
/* Read in a keystroke, and show the cursor while waiting. */
input = get_kbinput(edit, VISIBLE);
+ hide_cursor = FALSE;
+
#ifndef NANO_TINY
if (input == KEY_WINCH)
return;
diff --git a/src/prototypes.h b/src/prototypes.h
index f9ac3a9c..141d5322 100644
--- a/src/prototypes.h
+++ b/src/prototypes.h
@@ -53,6 +53,7 @@ extern message_type lastmessage;
extern linestruct *pletion_line;
extern bool also_the_last;
+extern bool hide_cursor;
extern char *answer;
diff --git a/src/search.c b/src/search.c
index 668c5d71..3ee435ff 100644
--- a/src/search.c
+++ b/src/search.c
@@ -327,6 +327,8 @@ int findnextstr(const char *needle, bool whole_word_only,
int modus,
openfile->mark = line;
openfile->mark_x = found_x + found_len;
openfile->softmark = TRUE;
+ if (!ISSET(SHOW_CURSOR))
+ hide_cursor = TRUE;
shift_held = TRUE;
}
#endif
diff --git a/src/winio.c b/src/winio.c
index e961cccb..4d259edf 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -178,7 +178,7 @@ void read_keys_from(WINDOW *win)
/* Before reading the first keycode, display any pending screen
updates. */
doupdate();
- if (reveal_cursor)
+ if (reveal_cursor && !hide_cursor)
curs_set(1);
/* Read in the first keycode, waiting for it to arrive. */
--
2.29.2