summaryrefslogtreecommitdiffstats
path: root/keymap.c
diff options
context:
space:
mode:
authorBrendan Cully <brendan@kublai.com>2008-08-30 19:59:42 -0700
committerBrendan Cully <brendan@kublai.com>2008-08-30 19:59:42 -0700
commit244feeb67478582fbf5597f25aaa9723e786d18a (patch)
tree941eb5a42cf47a8cb6e27e796685025584eb82f4 /keymap.c
parenta2976a0cfbd05a6ca1f8c6a71c14decf293bee69 (diff)
Rework timeout handling to support keepalive in the line editor.
Also allow keepalives of less than $timeout without returning before $timeout, so people who don't want to be notified of new mail don't have to be.
Diffstat (limited to 'keymap.c')
-rw-r--r--keymap.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/keymap.c b/keymap.c
index 18084d22..5de29954 100644
--- a/keymap.c
+++ b/keymap.c
@@ -387,25 +387,33 @@ int km_dokey (int menu)
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? */