]> granicus.if.org Git - neomutt/commitdiff
Change km_dokey() to pass SigWinch on for the MENU_EDITOR. (see #3877)
authorKevin McCarthy <kevin@8t8.us>
Wed, 5 Apr 2017 23:09:33 +0000 (16:09 -0700)
committerKevin McCarthy <kevin@8t8.us>
Wed, 5 Apr 2017 23:09:33 +0000 (16:09 -0700)
Change _mutt_enter_string() to pass the SigWinch through for
_mutt_get_field() or mutt_enter_string() to handle.

Add a call to mutt_current_menu() in _mutt_get_field() to properly
redisplay the screen in that case.

curs_lib.c
enter.c
keymap.c
menu.c
mutt_menu.h

index 041375741f2c9140d293ddefcfe39d4ddaf22c9d..3600ed8244c70fce4a1f95e892e699ee0800ec95 100644 (file)
@@ -162,6 +162,13 @@ int _mutt_get_field (const char *field, char *buf, size_t buflen, int complete,
   
   do
   {
+    if (SigWinch)
+    {
+      SigWinch = 0;
+      mutt_resize_screen ();
+      clearok(stdscr, TRUE);
+      mutt_current_menu_redraw ();
+    }
     mutt_window_clearline (MuttMessageWindow, 0);
     SETCOLOR (MT_COLOR_PROMPT);
     addstr ((char *)field); /* cast to get around bad prototypes */
@@ -173,7 +180,7 @@ int _mutt_get_field (const char *field, char *buf, size_t buflen, int complete,
   while (ret == 1);
   mutt_window_clearline (MuttMessageWindow, 0);
   mutt_free_enter_state (&es);
-  
+
   return (ret);
 }
 
diff --git a/enter.c b/enter.c
index cc985f2744cdb1e2bb7fbc4769a704d52648a44c..761b38d9c26bf27b40ee9b2943e56796d5fe6aa9 100644 (file)
--- a/enter.c
+++ b/enter.c
@@ -203,22 +203,40 @@ static inline int is_shell_char(wchar_t ch)
   return wcschr(shell_chars, ch) != NULL;
 }
 
-/*
+/* This function is for very basic input, currently used only by the
+ * built-in editor.  It does not handle screen redrawing on resizes
+ * well, because there is no active menu for the built-in editor.
+ * Most callers should prefer mutt_get_field() instead.
+ *
  * Returns:
- *     1 need to redraw the screen and call me again
  *     0 if input was given
  *     -1 if abort.
  */
-
 int  mutt_enter_string(char *buf, size_t buflen, int col, int flags)
 {
   int rv;
   ENTER_STATE *es = mutt_new_enter_state ();
-  rv = _mutt_enter_string (buf, buflen, col, flags, 0, NULL, NULL, es);
+  do
+  {
+    if (SigWinch)
+    {
+      SigWinch = 0;
+      mutt_resize_screen ();
+      clearok(stdscr, TRUE);
+    }
+    rv = _mutt_enter_string (buf, buflen, col, flags, 0, NULL, NULL, es);
+  }
+  while (rv == 1);
   mutt_free_enter_state (&es);
   return rv;
 }
 
+/*
+ * Returns:
+ *      1 need to redraw the screen and call me again
+ *     0 if input was given
+ *     -1 if abort.
+ */
 int _mutt_enter_string (char *buf, size_t buflen, int col,
                        int flags, int multiple, char ***files, int *numfiles,
                        ENTER_STATE *state)
@@ -297,7 +315,7 @@ int _mutt_enter_string (char *buf, size_t buflen, int col,
 
     if ((ch = km_dokey (MENU_EDITOR)) == -1)
     {
-      rv = -1; 
+      rv = SigWinch ? 1 : -1;
       goto bye;
     }
 
@@ -785,7 +803,7 @@ self_insert:
   }
   
   bye:
-  
+
   mutt_reset_history_state (hclass);
   FREE (&tempbuf);
   return rv;
index 07147bd218e765309083342499be2a99de29d36a..43db181c903e912130d000e318fae3701395deb4 100644 (file)
--- a/keymap.c
+++ b/keymap.c
@@ -464,8 +464,8 @@ int km_dokey (int menu)
 #ifdef USE_IMAP
   gotkey:
 #endif
-    /* hide timeouts and window resizes from line editor. */
-    if (menu == MENU_EDITOR && tmp.ch == -2)
+    /* hide timeouts, but not window resizes, from the line editor. */
+    if (menu == MENU_EDITOR && tmp.ch == -2 && !SigWinch)
       continue;
 
     LastKey = tmp.ch;
diff --git a/menu.c b/menu.c
index 5bbc4d7aa4f6b2cb9d094829ef9c77f474046f31..1b2d4facd432d7c6e5cb3f8970bbff3313c29c51 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -798,6 +798,22 @@ void mutt_set_menu_redraw_full (int menu_type)
     mutt_set_current_menu_redraw_full ();
 }
 
+void mutt_current_menu_redraw ()
+{
+  MUTTMENU *current_menu;
+
+  current_menu = get_current_menu ();
+  if (current_menu)
+  {
+    if (menu_redraw (current_menu) == OP_REDRAW)
+    /* On a REDRAW_FULL with a non-customized redraw, menu_redraw()
+     * will return OP_REDRAW to give the calling menu-loop a chance to
+     * customize output.
+     */
+       menu_redraw (current_menu);
+  }
+}
+
 
 #define MUTT_SEARCH_UP   1
 #define MUTT_SEARCH_DOWN 2
@@ -1012,7 +1028,6 @@ int mutt_menuLoop (MUTTMENU *menu)
     if (SigWinch)
     {
       mutt_resize_screen ();
-      menu->redraw = REDRAW_FULL;
       SigWinch = 0;
       clearok(stdscr,TRUE);/*force complete redraw*/
     }
index 5a34b1c2d1f536cdd6fc3cc501ba9f79caa83b7d..061b8dd2ea3043c28f8515e3aad2f3c5832d382f 100644 (file)
@@ -125,6 +125,7 @@ void mutt_pop_current_menu (MUTTMENU *);
 void mutt_set_current_menu_redraw (int);
 void mutt_set_current_menu_redraw_full ();
 void mutt_set_menu_redraw_full (int);
+void mutt_current_menu_redraw (void);
 int mutt_menuLoop (MUTTMENU *);
 
 /* used in both the index and pager index to make an entry. */