From fe012dad9110ea1f126d7a0bb83ea9ea792eef81 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg <bensberg@justemail.net> Date: Sun, 25 Dec 2016 12:42:33 +0100 Subject: [PATCH] help: when searching, do it forward, without case, and without regexes Also, save and restore all the flags in a single swoop. --- src/help.c | 49 +++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 28 deletions(-) diff --git a/src/help.c b/src/help.c index 3ef53d1b..68858861 100644 --- a/src/help.c +++ b/src/help.c @@ -76,12 +76,7 @@ void display_the_help_text(bool redisplaying) if (redisplaying) close_buffer(); - if (!ISSET(MULTIBUFFER)) { - SET(MULTIBUFFER); - open_buffer(tempfilename, FALSE); - UNSET(MULTIBUFFER); - } else - open_buffer(tempfilename, FALSE); + open_buffer(tempfilename, FALSE); display_buffer(); @@ -100,8 +95,6 @@ void display_the_help_text(bool redisplaying) void do_help(void) { int kbinput = ERR; - bool old_no_help = ISSET(NO_HELP); - bool was_whitespace = ISSET(WHITESPACE_DISPLAY); int oldmenu = currmenu; /* The menu we were called from. */ const char *ptr; @@ -111,10 +104,12 @@ void do_help(void) FILE *fp; filestruct *line; int line_size; - int saved_margin = 0; + int saved_margin = margin; /* For avoiding the line numbers on the help screen. */ char *saved_answer = (answer != NULL) ? strdup(answer) : NULL; /* Store current answer when user invokes help at the prompt. */ + unsigned stash[sizeof(flags) / sizeof(flags[0])]; + /* A storage place for the current flag settings. */ blank_statusbar(); @@ -134,25 +129,30 @@ void do_help(void) inhelp = TRUE; location = 0; - if (ISSET(NO_HELP)) { - /* Make sure that the help screen's shortcut list will actually - * be displayed. */ + /* Save the settings of all flags. */ + memcpy(stash, flags, sizeof(flags)); + + /* Ensure that the help screen's shortcut list can be displayed. */ + if (ISSET(NO_HELP) && LINES > 4) { UNSET(NO_HELP); window_init(); } UNSET(WHITESPACE_DISPLAY); UNSET(NOREAD_MODE); + SET(MULTIBUFFER); + + /* When searching, do it forward, case insensitive, and without regexes. */ + UNSET(BACKWARDS_SEARCH); + UNSET(CASE_SENSITIVE); + UNSET(USE_REGEXP); bottombars(MHELP); wnoutrefresh(bottomwin); #ifdef ENABLE_LINENUMBERS - if (ISSET(LINE_NUMBERS)) { - saved_margin = margin; - margin = 0; - UNSET(LINE_NUMBERS); - } + UNSET(LINE_NUMBERS); + margin = 0; #endif /* Extract the title from the head of the help text. */ @@ -235,28 +235,21 @@ void do_help(void) } } - /* We're exiting from the help screen. So, restore the flags and the - * original menu, refresh the entire screen and deallocate the memory. */ + /* Restore the settings of all flags. */ + memcpy(flags, stash, sizeof(flags)); #ifdef ENABLE_LINENUMBERS - if (saved_margin != 0) { - margin = saved_margin; - SET(LINE_NUMBERS); - } + margin = saved_margin; #endif - if (old_no_help) { + if (ISSET(NO_HELP)) { blank_bottombars(); wnoutrefresh(bottomwin); currmenu = oldmenu; - SET(NO_HELP); window_init(); } else bottombars(oldmenu); - if (was_whitespace) - SET(WHITESPACE_DISPLAY); - free(title); title = NULL; inhelp = FALSE; -- GitLab