]> granicus.if.org Git - neomutt/commitdiff
Change km_dokey() to return -2 on a timeout/sigwinch.
authorKevin McCarthy <kevin@8t8.us>
Thu, 1 Jun 2017 22:17:01 +0000 (15:17 -0700)
committerKevin McCarthy <kevin@8t8.us>
Thu, 1 Jun 2017 22:17:01 +0000 (15:17 -0700)
In some cases, such as tag-prefix or _mutt_enter_string(), it is
desirable to be able to distinguish between a timeout/sigwinch event
and an input error/abort/ctrl-g.

curs_main.c
enter.c
keymap.c
menu.c
pager.c

index f5aeb1b55d735b7527b710c846002defde90f00d..e0c2497b5dfe84a96ba3c212a24d66c917ee291d 100644 (file)
@@ -664,7 +664,7 @@ int mutt_index_menu (void)
        do_buffy_notify = 1;
     }
 
-    if (op != -1)
+    if (op >= 0)
       mutt_curs_set (0);
 
     if (menu->menu == MENU_MAIN)
@@ -705,7 +705,7 @@ int mutt_index_menu (void)
 
       dprint(4, (debugfile, "mutt_index_menu[%d]: Got op %d\n", __LINE__, op));
 
-      if (op == -1)
+      if (op < 0)
        continue; /* either user abort or timeout */
 
       mutt_curs_set (1);
@@ -1342,7 +1342,7 @@ int mutt_index_menu (void)
          * set CurrentMenu incorrectly when we return back to the index menu. */
         menu->menu = MENU_MAIN;
 
-        if ((op = mutt_display_message (CURHDR)) == -1)
+        if ((op = mutt_display_message (CURHDR)) < 0)
        {
          unset_option (OPTNEEDRESORT);
          break;
diff --git a/enter.c b/enter.c
index fd012812a1e69964627b76cbacc5c2d6df60373c..188cf295d3f478fe9af113d059342f6153f629d3 100644 (file)
--- a/enter.c
+++ b/enter.c
@@ -315,9 +315,9 @@ int _mutt_enter_string (char *buf, size_t buflen, int col,
     }
     mutt_refresh ();
 
-    if ((ch = km_dokey (MENU_EDITOR)) == -1)
+    if ((ch = km_dokey (MENU_EDITOR)) < 0)
     {
-      rv = SigWinch ? 1 : -1;
+      rv = (SigWinch && ch == -2) ? 1 : -1;
       goto bye;
     }
 
index a3deb7d89c8d5931eda2ae9ec27de3805ec732f8..6a290413e8e9d933c74574d2ce9d4183a7f695dd 100644 (file)
--- a/keymap.c
+++ b/keymap.c
@@ -418,6 +418,7 @@ static int retry_generic (int menu, keycode_t *keys, int keyslen, int lastkey)
  *     >0              function to execute
  *     OP_NULL         no function bound to key sequence
  *     -1              error occurred while reading input
+ *     -2              a timeout or sigwinch occurred
  */
 int km_dokey (int menu)
 {
@@ -470,7 +471,7 @@ int km_dokey (int menu)
 
     LastKey = tmp.ch;
     if (LastKey < 0)
-      return -1;
+      return LastKey;
 
     /* do we have an op already? */
     if (tmp.op)
diff --git a/menu.c b/menu.c
index 5a166f2ba836bf8821dc2922c7290f71ee81708a..0e09c78005ad857849251c31a0e95f61358906ab 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -1045,7 +1045,7 @@ int mutt_menuLoop (MUTTMENU *menu)
     }
 #endif
 
-    if (i == -1)
+    if (i < 0)
       continue;
 
     if (!menu->dialog)
diff --git a/pager.c b/pager.c
index a45febb74a761d4e782c1acdca898a65056d7311..f83331468a4a304be4e5648c9cbe730cf65e342e 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -2013,7 +2013,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
       OldHdr = NULL;
       
     ch = km_dokey (MENU_PAGER);
-    if (ch != -1)
+    if (ch >= 0)
       mutt_clear_error ();
     mutt_curs_set (1);
 
@@ -2050,7 +2050,7 @@ mutt_pager (const char *banner, const char *fname, int flags, pager_t *extra)
       continue;
     }
 #endif
-    if (ch == -1)
+    if (ch < 0)
     {
       ch = 0;
       continue;