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

Also, save and restore all the flags in a single swoop.
master
Benno Schulenberg 2016-12-25 12:42:33 +01:00
parent 3787494c15
commit fe012dad91
1 changed files with 21 additions and 28 deletions

View File

@ -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;