{
int ch;
event_t err = {-1, OP_NULL }, ret;
+ event_t timeout = {-2, OP_NULL};
if (!option(OPTUNBUFFEREDINPUT) && UngetCount)
return (KeyEvent[--UngetCount]);
endwin ();
exit (1);
}
- return err;
+ return timeout;
}
if ((ch & 0x80) && option (OPTMETAKEY))
ch = mutt_getch ();
if (CI_is_return (ch.ch))
break;
- if (ch.ch == -1)
+ if (ch.ch < 0)
{
def = -1;
break;
mutt_refresh ();
ch = mutt_getch();
- if (ch.ch == -1)
+ if (ch.ch < 0)
{
CLEARLINE (LINES-1);
return (-1);
{
mutt_refresh ();
ch = mutt_getch ();
- if (ch.ch == -1 || CI_is_return (ch.ch))
+ if (ch.ch < 0 || CI_is_return (ch.ch))
{
choice = -1;
break;
FOREVER
{
- /* ncurses doesn't return on resized screen when timeout is set to zero */
- if (menu != MENU_EDITOR)
- {
- i = Timeout > 0 ? Timeout : 60;
+ i = Timeout > 0 ? Timeout : 60;
#ifdef USE_IMAP
+ /* keepalive may need to run more frequently than Timeout allows */
+ while (ImapKeepalive && ImapKeepalive < i)
+ {
+ timeout (ImapKeepalive * 1000);
+ tmp = mutt_getch ();
+ timeout (-1);
+ if (tmp.ch != -2)
+ /* something other than timeout */
+ goto gotkey;
+ i -= ImapKeepalive;
imap_keepalive ();
- if (ImapKeepalive && ImapKeepalive < i)
- i = ImapKeepalive;
-#endif
- timeout (i * 1000);
}
+#endif
+ timeout (i * 1000);
tmp = mutt_getch();
+ timeout (-1);
- if (menu != MENU_EDITOR)
- timeout (-1); /* restore blocking operation */
+ /* hide timeouts from line editor */
+ if (menu == MENU_EDITOR && tmp.ch == -2)
+ continue;
+ gotkey:
LastKey = tmp.ch;
- if (LastKey == -1)
+ if (LastKey < 0)
return -1;
/* do we have an op already? */