diff options
author | John Hawthorn <john@hawthorn.email> | 2018-09-15 13:55:10 -0700 |
---|---|---|
committer | John Hawthorn <john@hawthorn.email> | 2018-09-23 11:23:53 -0700 |
commit | 76e5f30d19b0d9306a192d48ebad3d17a29bc3cf (patch) | |
tree | d3863d35188c5311d6537c848198b69a0c3f127a /src | |
parent | 249b6c94a90ce03dd79cac23ba7d03e3bc7cd164 (diff) |
Pass a timeout to tty_input_ready
Diffstat (limited to 'src')
-rw-r--r-- | src/tty.c | 4 | ||||
-rw-r--r-- | src/tty.h | 2 | ||||
-rw-r--r-- | src/tty_interface.c | 2 |
3 files changed, 4 insertions, 4 deletions
@@ -89,9 +89,9 @@ char tty_getchar(tty_t *tty) { } } -int tty_input_ready(tty_t *tty, int pending) { +int tty_input_ready(tty_t *tty, unsigned long timeout) { fd_set readfs; - struct timeval tv = {0, pending ? (KEYTIMEOUT * 1000) : 0}; + struct timeval tv = {timeout / 1000, (timeout % 1000) * 1000}; FD_ZERO(&readfs); FD_SET(tty->fdin, &readfs); select(tty->fdin + 1, &readfs, NULL, NULL, &tv); @@ -17,7 +17,7 @@ void tty_close(tty_t *tty); void tty_init(tty_t *tty, const char *tty_filename); void tty_getwinsz(tty_t *tty); char tty_getchar(tty_t *tty); -int tty_input_ready(tty_t *tty, int pending); +int tty_input_ready(tty_t *tty, unsigned long timeout); void tty_setfg(tty_t *tty, int fg); void tty_setinvert(tty_t *tty); diff --git a/src/tty_interface.c b/src/tty_interface.c index f6aeef0..5839af7 100644 --- a/src/tty_interface.c +++ b/src/tty_interface.c @@ -373,7 +373,7 @@ int tty_interface_run(tty_interface_t *state) { return state->exit; draw(state); - } while (tty_input_ready(state->tty, state->ambiguous_key_pending)); + } while (tty_input_ready(state->tty, state->ambiguous_key_pending ? KEYTIMEOUT : 0)); if (state->ambiguous_key_pending) { char s[1] = ""; |