From: Kevin McCarthy Date: Thu, 1 Jun 2017 22:17:01 +0000 (-0700) Subject: Change km_dokey() to return -2 on a timeout/sigwinch. X-Git-Tag: neomutt-20170707^2^2~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=45e430bd1abc9a90eb2f6f15955c3e34c92cce05;p=neomutt Change km_dokey() to return -2 on a timeout/sigwinch. 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. --- diff --git a/curs_main.c b/curs_main.c index f5aeb1b55..e0c2497b5 100644 --- a/curs_main.c +++ b/curs_main.c @@ -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 fd012812a..188cf295d 100644 --- 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; } diff --git a/keymap.c b/keymap.c index a3deb7d89..6a290413e 100644 --- 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 5a166f2ba..0e09c7800 100644 --- 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 a45febb74..f83331468 100644 --- 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;