nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] [PATCH] display: first attempt at making --nohelp effective


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH] display: first attempt at making --nohelp effective only in main menu
Date: Thu, 23 Aug 2018 20:40:53 +0200

A major problem is that when cancelling a search (for example), then
the "Cancelled" message gets written while the two help lines are still
there, but then the edit window gets rewritten without those two lines,
meaning that the status bar and the message get plastered over.  :|
I don't know how to fix that.
---
 src/help.c   | 19 +------------------
 src/nano.c   |  3 ++-
 src/prompt.c |  2 --
 src/winio.c  | 29 +++++++++++++++++++++++++++--
 4 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/src/help.c b/src/help.c
index 0d024e5f..6dd1675e 100644
--- a/src/help.c
+++ b/src/help.c
@@ -129,12 +129,6 @@ void do_help(void)
        /* 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();
-       }
-
        /* When searching, do it forward, case insensitive, and without 
regexes. */
        UNSET(BACKWARDS_SEARCH);
        UNSET(CASE_SENSITIVE);
@@ -263,22 +257,11 @@ void do_help(void)
        /* Switch back to the buffer we were invoked from. */
        switch_to_prev_buffer();
 
-       if (ISSET(NO_HELP)) {
-               currmenu = oldmenu;
-               window_init();
-       } else
-               bottombars(oldmenu);
-
        free(title);
        title = NULL;
        inhelp = FALSE;
 
-#ifdef ENABLE_BROWSER
-       if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == 
MGOTODIR)
-               browser_refresh();
-       else
-#endif
-               total_refresh();
+       bottombars(oldmenu);
 
        free(answer);
        answer = saved_answer;
diff --git a/src/nano.c b/src/nano.c
index e891f7b5..b05709c1 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -699,7 +699,8 @@ void window_init(void)
                bottomwin = newwin(1, COLS, LINES - 1, 0);
        } else {
                int toprows = (ISSET(MORE_SPACE) ? 1 : (LINES < 6) ? 1 : 2);
-               int bottomrows = (ISSET(NO_HELP) ? 1 : (LINES < 5) ? 1 : 3);
+               int bottomrows = (ISSET(NO_HELP) && (currmenu == MMAIN || 
currmenu == MMOST) ?
+                                                                               
        1 : (LINES < 5) ? 1 : 3);
 
                editwinrows = LINES - toprows - bottomrows;
 
diff --git a/src/prompt.c b/src/prompt.c
index e3e394ef..46cc5d2e 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -675,7 +675,6 @@ int do_yesno_prompt(bool all, const char *msg)
 #endif
                int kbinput;
 
-               if (!ISSET(NO_HELP)) {
                        char shortstr[MAXCHARLEN + 2];
                                /* Temporary string for (translated) " Y", " N" 
and " A". */
                        const sc *cancelshortcut = first_sc_for(MYESNO, 
do_cancel);
@@ -704,7 +703,6 @@ int do_yesno_prompt(bool all, const char *msg)
 
                        wmove(bottomwin, 2, width);
                        post_one_key(cancelshortcut->keystr, _("Cancel"), 
width);
-               }
 
                /* Color the statusbar over its full width and display the 
question. */
                wattron(bottomwin, interface_color_pair[TITLE_BAR]);
diff --git a/src/winio.c b/src/winio.c
index e32e7d55..b9f18ccf 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -1821,7 +1821,7 @@ void wipe_statusbar(void)
  * portion of the window. */
 void blank_bottombars(void)
 {
-       if (!ISSET(NO_HELP) && LINES > 4) {
+       if ((!ISSET(NO_HELP) || currmenu != MMAIN) && LINES > 4) {
                blank_row(bottomwin, 1, 0, COLS);
                blank_row(bottomwin, 2, 0, COLS);
        }
@@ -2263,13 +2263,25 @@ void bottombars(int menu)
        size_t number, itemwidth, i;
        subnfunc *f;
        const sc *s;
+       int wasmenu = currmenu;
 
        /* Set the global variable to the given menu. */
        currmenu = menu;
 
-       if (ISSET(NO_HELP) || LINES < 5)
+       if ((ISSET(NO_HELP) && wasmenu == MMOST) || LINES < 5)
                return;
 
+       /* If in the main menu there are no help lines, and we come from
+        * or go to the main menu, then resize the subwindows. */
+       if (ISSET(NO_HELP) && (wasmenu == MMAIN || menu == MMAIN)) {
+               window_init();
+
+               if (menu == MMAIN) {
+                       edit_refresh();
+                       return;
+               }
+       }
+
        /* Determine how many shortcuts there are to show. */
        number = length_of_list(menu);
 
@@ -2304,6 +2316,19 @@ void bottombars(int menu)
        /* Defeat a VTE bug by homing the cursor and forcing a screen update. */
        wmove(bottomwin, 0, 0);
        wrefresh(bottomwin);
+
+       focusing = FALSE;
+
+#ifdef ENABLE_BROWSER
+       if (menu == MBROWSER || menu == MWHEREISFILE || menu == MGOTODIR)
+               browser_refresh();
+       else
+#endif
+       {
+               if (!inhelp)
+                       titlebar(NULL);
+               edit_refresh();
+       }
 }
 
 /* Write a key's representation plus a minute description of its function
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]