diff --git a/src/browser.c b/src/browser.c index 87e82050a045e73ca05ed8c5780b64c00fdf5202..3c049dd311c0703e85b4eb2d97785a3889ba0d86 100644 --- a/src/browser.c +++ b/src/browser.c @@ -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. */ diff --git a/src/files.c b/src/files.c index 7d9abcf3eb14e439fa34bd85e62a45955ab9768d..fb1c34b4fc7f1f19538f3105b7c75b5fbeb87c93 100644 --- a/src/files.c +++ b/src/files.c @@ -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 diff --git a/src/global.c b/src/global.c index 1e15b177dec740c4c77ab567d40a45b3fcce0eca..fb8cce2e52000dfcd1f396f3aaaea22a1a1b7ad7 100644 --- a/src/global.c +++ b/src/global.c @@ -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; diff --git a/src/nano.c b/src/nano.c index b53e1f04a4ea59ec5ffb1be49951be85467f5ad1..d19004418e6d61afa1f89de247579a5821b4c93d 100644 --- a/src/nano.c +++ b/src/nano.c @@ -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; diff --git a/src/prompt.c b/src/prompt.c index 0c94242651d515f924028fc64bd3c9fcbaaefaeb..c492716e0dac61b2520873b7055170fba31d203b 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -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; } diff --git a/src/search.c b/src/search.c index f72415759e8999232400e5e43a96c8d3da6e42f6..e62a4c47a6ea096063b8dab960be51201d672205 100644 --- a/src/search.c +++ b/src/search.c @@ -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 diff --git a/src/text.c b/src/text.c index 8800bdd083cee1d4bb1a476bb6783a3626faa0a1..f0f611dcd03422789fd5e198818679c3a3db6d28 100644 --- a/src/text.c +++ b/src/text.c @@ -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