main: let the main loop restore the main menu, if needed

Don't make it the responsibility of the executed functions to restore
the list of shortcuts of the edit window.  Just detect whether another
menu was displayed, and if so, redisplay the main menu.
master
Benno Schulenberg 2016-05-08 12:01:33 +02:00
parent 17fb6dfdc0
commit 9106cc8ecc
7 changed files with 19 additions and 38 deletions

View File

@ -131,6 +131,8 @@ char *do_browser(char *path)
curs_set(0);
lastmessage = HUSH;
bottombars(MBROWSER);
#ifndef NANO_TINY
if (kbinput == KEY_WINCH) {
/* Remember the selected file, to be able to reselect it. */
@ -245,9 +247,6 @@ char *do_browser(char *path)
#endif
/* TRANSLATORS: This is a prompt. */
browser_refresh, _("Go To Directory"));
bottombars(MBROWSER);
/* If the directory begins with a newline (i.e. an
* encoded null), treat it as though it's blank. */
if (i < 0 || *answer == '\n') {
@ -782,11 +781,9 @@ void findnextfile(const char *needle)
/* Search for a filename. */
void do_filesearch(void)
{
if (filesearch_init() != 0) {
/* Cancelled, or a blank search string, or done something. */
bottombars(MBROWSER);
/* If the user cancelled or jumped to first or last file, don't search. */
if (filesearch_init() != 0)
return;
}
/* If answer is now "", copy last_search into answer. */
if (*answer == '\0')
@ -801,8 +798,6 @@ void do_filesearch(void)
#endif
findnextfile(answer);
bottombars(MBROWSER);
}
/* Search again for the last given filename, without prompting. */

View File

@ -590,7 +590,6 @@ void switch_to_prevnext_buffer(bool to_next)
#ifdef DEBUG
dump_filestruct(openfile->current);
#endif
display_main_list();
}
/* Switch to the previous entry in the openfile filebuffer. */
@ -1342,8 +1341,6 @@ void do_insertfile_void(void)
FALSE
#endif
);
display_main_list();
}
/* When passed "[relative path]" or "[relative path][filename]" in
@ -2474,8 +2471,6 @@ void do_writeout_void(void)
/* If the user chose to discard the buffer, close it. */
if (do_writeout(FALSE) == 2)
close_and_go();
display_main_list();
}
#ifndef NANO_TINY

View File

@ -167,8 +167,8 @@ bool refresh_needed = FALSE;
/* Did a command mangle enough of the buffer that we should
* repaint the screen? */
int currmenu;
/* The currently loaded menu. */
int currmenu = MMOST;
/* The currently active menu, initialized to a dummy value. */
sc *sclist = NULL;
/* Pointer to the start of the shortcuts list. */
subnfunc *allfuncs = NULL;

View File

@ -1112,8 +1112,6 @@ void do_exit(void)
close_and_go();
else if (i != 1)
statusbar(_("Cancelled"));
display_main_list();
}
/* Close the current buffer, and terminate nano if it was the last. */
@ -2635,12 +2633,12 @@ int main(int argc, char **argv)
fprintf(stderr, "Main: bottom win, top win and edit win\n");
#endif
display_main_list();
display_buffer();
while (TRUE) {
currmenu = MMAIN;
if (currmenu != MMAIN)
display_main_list();
focusing = TRUE;
lastmessage = HUSH;

View File

@ -917,6 +917,8 @@ int do_yesno_prompt(bool all, const char *msg)
}
} while (response == -2);
currmenu = oldmenu;
/* Restore the previously active menu. */
bottombars(oldmenu);
return response;
}

View File

@ -104,7 +104,6 @@ void not_found_msg(const char *str)
* search, if any. */
void search_replace_abort(void)
{
display_main_list();
#ifndef NANO_TINY
if (openfile->mark_set)
edit_refresh();
@ -916,7 +915,6 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
/* Cancel, or Enter with blank string. */
if (i < 0) {
statusbar(_("Cancelled"));
display_main_list();
return;
}
@ -937,7 +935,6 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
line < 1 || column < 1) {
if (i == 0)
statusbar(_("Invalid line or column number"));
display_main_list();
return;
}
} else {
@ -959,7 +956,6 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
if (interactive) {
edit_update(CENTERING);
edit_refresh();
display_main_list();
} else {
/* If the target line is close to the tail of the file, put the last
* line of the file on the bottom line of the screen; otherwise, just

View File

@ -3139,8 +3139,6 @@ void do_spell(void)
unlink(temp);
free(temp);
currmenu = MMAIN;
/* If the spell-checker printed any error messages onscreen, make
* sure that they're cleared off. */
total_refresh();
@ -3187,16 +3185,16 @@ void do_linter(void)
if (i == -1) {
statusbar(_("Cancelled"));
goto exit_from_lint;
return;
} else if (i == 1 && (do_writeout(FALSE) != TRUE))
goto exit_from_lint;
return;
}
lintcopy = mallocstrcpy(NULL, openfile->syntax->linter);
/* Create a pipe up front. */
if (pipe(lint_fd) == -1) {
statusbar(_("Could not create pipe"));
goto exit_from_lint;
return;
}
blank_bottombars();
@ -3244,14 +3242,14 @@ void do_linter(void)
if (pid_lint < 0) {
close(lint_fd[0]);
statusbar(_("Could not fork"));
goto exit_from_lint;
return;
}
/* Get the system pipe buffer size. */
if ((pipe_buff_size = fpathconf(lint_fd[0], _PC_PIPE_BUF)) < 1) {
close(lint_fd[0]);
statusbar(_("Could not get size of pipe buffer"));
goto exit_from_lint;
return;
}
/* Read in the returned syntax errors. */
@ -3349,7 +3347,7 @@ void do_linter(void)
if (!WIFEXITED(lint_status) || WEXITSTATUS(lint_status) > 2) {
statusbar(invocation_error(openfile->syntax->linter));
goto exit_from_lint;
return;
}
free(read_buff);
@ -3357,7 +3355,7 @@ void do_linter(void)
if (parsesuccess == 0) {
statusline(HUSH, _("Got 0 parsable lines from command: %s"),
openfile->syntax->linter);
goto exit_from_lint;
return;
}
bottombars(MLINTER);
@ -3464,9 +3462,6 @@ void do_linter(void)
free(tmplint->filename);
free(tmplint);
}
exit_from_lint:
display_main_list();
}
#ifndef DISABLE_SPELLER