Commit 054164bf authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

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.
parent 5f93694f
......@@ -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;
......
......@@ -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;
}
......
......@@ -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)
......
......@@ -1045,7 +1045,7 @@ int mutt_menuLoop (MUTTMENU *menu)
}
#endif
if (i == -1)
if (i < 0)
continue;
if (!menu->dialog)
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment