fzy

terminal fuzzy finder picker

git clone https://9o.is/git/fzy.git

commit 5a0d76761d66280be063c63e26054bdf15b0c568
parent fe7636db91e629f233d39a673996b2d4d8d4085e
Author: John Hawthorn <john@hawthorn.email>
Date:   Sat, 15 Sep 2018 13:55:10 -0700

Pass a timeout to tty_input_ready

Diffstat:
Msrc/tty.c | 4++--
Msrc/tty.h | 2+-
Msrc/tty_interface.c | 2+-
3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/tty.c b/src/tty.c @@ -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); diff --git a/src/tty.h b/src/tty.h @@ -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 @@ -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] = "";