commit 9c2bc68847f6926dff692c927dbd791a91a96330
parent 3d1ef8e07f32a2b822585eb1b1673dcb4ea5971c
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Wed, 3 May 2017 12:41:24 +0200
help: after a search, show the cursor only when something was found
And hide the cursor again as soon as the user scrolls.
Achieve this through making the 'didfind' variable global.
Also, remove a superfluous call of wnoutrefresh(), as bottombars()
already does that.
This fixes https://savannah.gnu.org/bugs/?50918.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
Diffstat:
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/global.c b/src/global.c
@@ -68,6 +68,9 @@ bool inhelp = FALSE;
char *title = NULL;
/* When not NULL: the title of the current help text. */
+int didfind = 0;
+ /* Whether the last search found something. */
+
int controlleft, controlright, controlup, controldown, controlhome, controlend;
#ifndef NANO_TINY
int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
diff --git a/src/help.c b/src/help.c
@@ -183,6 +183,7 @@ void do_help(void)
while (TRUE) {
lastmessage = HUSH;
focusing = TRUE;
+ didfind = 0;
kbinput = get_kbinput(edit);
@@ -207,12 +208,9 @@ void do_help(void)
} else if (func == do_search) {
do_search();
bottombars(MHELP);
- wnoutrefresh(bottomwin);
- curs_set(1);
} else if (func == do_research) {
do_research();
currmenu = MHELP;
- curs_set(1);
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
@@ -229,6 +227,12 @@ void do_help(void)
} else
unbound_key(kbinput);
+ /* If we searched and found something, let the cursor show it. */
+ if (didfind == 1)
+ curs_set(1);
+ else
+ curs_set(0);
+
edit_refresh();
location = 0;
diff --git a/src/proto.h b/src/proto.h
@@ -54,6 +54,8 @@ extern filestruct *pletion_line;
extern bool inhelp;
extern char *title;
+extern int didfind;
+
extern int controlleft;
extern int controlright;
extern int controlup;
diff --git a/src/search.c b/src/search.c
@@ -438,7 +438,6 @@ void go_looking(void)
{
filestruct *was_current = openfile->current;
size_t was_current_x = openfile->current_x;
- int didfind;
#ifdef DEBUG
clock_t start = clock();
#endif