Commit fe012dad authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

help: when searching, do it forward, without case, and without regexes

Also, save and restore all the flags in a single swoop.
No related merge requests found
Showing with 21 additions and 28 deletions
+21 -28
...@@ -76,12 +76,7 @@ void display_the_help_text(bool redisplaying) ...@@ -76,12 +76,7 @@ void display_the_help_text(bool redisplaying)
if (redisplaying) if (redisplaying)
close_buffer(); close_buffer();
if (!ISSET(MULTIBUFFER)) { open_buffer(tempfilename, FALSE);
SET(MULTIBUFFER);
open_buffer(tempfilename, FALSE);
UNSET(MULTIBUFFER);
} else
open_buffer(tempfilename, FALSE);
display_buffer(); display_buffer();
...@@ -100,8 +95,6 @@ void display_the_help_text(bool redisplaying) ...@@ -100,8 +95,6 @@ void display_the_help_text(bool redisplaying)
void do_help(void) void do_help(void)
{ {
int kbinput = ERR; int kbinput = ERR;
bool old_no_help = ISSET(NO_HELP);
bool was_whitespace = ISSET(WHITESPACE_DISPLAY);
int oldmenu = currmenu; int oldmenu = currmenu;
/* The menu we were called from. */ /* The menu we were called from. */
const char *ptr; const char *ptr;
...@@ -111,10 +104,12 @@ void do_help(void) ...@@ -111,10 +104,12 @@ void do_help(void)
FILE *fp; FILE *fp;
filestruct *line; filestruct *line;
int line_size; int line_size;
int saved_margin = 0; int saved_margin = margin;
/* For avoiding the line numbers on the help screen. */ /* For avoiding the line numbers on the help screen. */
char *saved_answer = (answer != NULL) ? strdup(answer) : NULL; char *saved_answer = (answer != NULL) ? strdup(answer) : NULL;
/* Store current answer when user invokes help at the prompt. */ /* 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(); blank_statusbar();
...@@ -134,25 +129,30 @@ void do_help(void) ...@@ -134,25 +129,30 @@ void do_help(void)
inhelp = TRUE; inhelp = TRUE;
location = 0; location = 0;
if (ISSET(NO_HELP)) { /* Save the settings of all flags. */
/* Make sure that the help screen's shortcut list will actually memcpy(stash, flags, sizeof(flags));
* be displayed. */
/* Ensure that the help screen's shortcut list can be displayed. */
if (ISSET(NO_HELP) && LINES > 4) {
UNSET(NO_HELP); UNSET(NO_HELP);
window_init(); window_init();
} }
UNSET(WHITESPACE_DISPLAY); UNSET(WHITESPACE_DISPLAY);
UNSET(NOREAD_MODE); 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); bottombars(MHELP);
wnoutrefresh(bottomwin); wnoutrefresh(bottomwin);
#ifdef ENABLE_LINENUMBERS #ifdef ENABLE_LINENUMBERS
if (ISSET(LINE_NUMBERS)) { UNSET(LINE_NUMBERS);
saved_margin = margin; margin = 0;
margin = 0;
UNSET(LINE_NUMBERS);
}
#endif #endif
/* Extract the title from the head of the help text. */ /* Extract the title from the head of the help text. */
...@@ -235,28 +235,21 @@ void do_help(void) ...@@ -235,28 +235,21 @@ void do_help(void)
} }
} }
/* We're exiting from the help screen. So, restore the flags and the /* Restore the settings of all flags. */
* original menu, refresh the entire screen and deallocate the memory. */ memcpy(flags, stash, sizeof(flags));
#ifdef ENABLE_LINENUMBERS #ifdef ENABLE_LINENUMBERS
if (saved_margin != 0) { margin = saved_margin;
margin = saved_margin;
SET(LINE_NUMBERS);
}
#endif #endif
if (old_no_help) { if (ISSET(NO_HELP)) {
blank_bottombars(); blank_bottombars();
wnoutrefresh(bottomwin); wnoutrefresh(bottomwin);
currmenu = oldmenu; currmenu = oldmenu;
SET(NO_HELP);
window_init(); window_init();
} else } else
bottombars(oldmenu); bottombars(oldmenu);
if (was_whitespace)
SET(WHITESPACE_DISPLAY);
free(title); free(title);
title = NULL; title = NULL;
inhelp = FALSE; inhelp = FALSE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment