fzy
terminal fuzzy finder picker
git clone https://9o.is/git/fzy.git
commit e5a95c11d7532e5ad29c7b76b71e31a80a6208d4 parent 668b3551d9a390610b2d4b2fdcd7ebbfddb517dc Author: John Hawthorn <john.hawthorn@gmail.com> Date: Sun, 19 Oct 2014 16:19:24 -0700 termios should be reset on successful exit. Still needs to be fixed on an exit due to ^C Thanks @rtandy Diffstat:
| M | fzy.c | | | 2 | +- |
| M | tty.c | | | 6 | ++++++ |
| M | tty.h | | | 1 | + |
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/fzy.c b/fzy.c @@ -157,7 +157,7 @@ void run(tty_t *tty, choices_t *choices){ clear(tty); /* ttyout should be flushed before outputting on stdout */ - fclose(tty->fout); + tty_close(tty); emit(choices); }else if(ch == 27){ /* ESC */ diff --git a/tty.c b/tty.c @@ -12,6 +12,12 @@ void tty_reset(tty_t *tty){ tcsetattr(tty->fdin, TCSANOW, &tty->original_termios); } +void tty_close(tty_t *tty){ + tty_reset(tty); + fclose(tty->fout); + close(tty->fdin); +} + void tty_init(tty_t *tty, const char *tty_filename){ tty->fdin = open(tty_filename, O_RDONLY); tty->fout = fopen(tty_filename, "w"); diff --git a/tty.h b/tty.h @@ -13,6 +13,7 @@ typedef struct{ } tty_t; void tty_reset(tty_t *tty); +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);