diff options
author | Brendan Cully <brendan@kublai.com> | 2008-08-30 19:59:42 -0700 |
---|---|---|
committer | Brendan Cully <brendan@kublai.com> | 2008-08-30 19:59:42 -0700 |
commit | 244feeb67478582fbf5597f25aaa9723e786d18a (patch) | |
tree | 941eb5a42cf47a8cb6e27e796685025584eb82f4 /keymap.c | |
parent | a2976a0cfbd05a6ca1f8c6a71c14decf293bee69 (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.c | 30 |
1 files changed, 19 insertions, 11 deletions
@@ -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? */ |