fzy

terminal fuzzy finder picker

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

commit 08ad607d492e482763c53b93f1abb6484547b9ac
parent e697cbef80e9896a8fe1deec0472600561c6bb1e
Author: John Hawthorn <john@hawthorn.email>
Date:   Sat, 15 Sep 2018 17:15:42 -0700

Allow -1 timeout to mean infinite

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

diff --git a/src/tty.c b/src/tty.c @@ -96,7 +96,7 @@ char tty_getchar(tty_t *tty) { } } -int tty_input_ready(tty_t *tty, unsigned long timeout, int return_on_signal) { +int tty_input_ready(tty_t *tty, long int timeout, int return_on_signal) { fd_set readfs; FD_ZERO(&readfs); FD_SET(tty->fdin, &readfs); @@ -108,7 +108,13 @@ int tty_input_ready(tty_t *tty, unsigned long timeout, int return_on_signal) { if (!return_on_signal) sigaddset(&mask, SIGWINCH); - int err = pselect(tty->fdin + 1, &readfs, NULL, NULL, &ts, &mask); + int err = pselect( + tty->fdin + 1, + &readfs, + NULL, + NULL, + timeout < 0 ? NULL : &ts, + return_on_signal ? NULL : &mask); if (err < 0) { return 0; 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 timeout, int return_on_signal); +int tty_input_ready(tty_t *tty, long int timeout, int return_on_signal); void tty_setfg(tty_t *tty, int fg); void tty_setinvert(tty_t *tty);