fzy

terminal fuzzy finder picker

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

commit 58d9ff0dc00110f0b62b768dd4d3e7e927a0ce2f
parent 547a68b8216cb39726772c480a51afa32188b72b
Author: John Hawthorn <john.hawthorn@gmail.com>
Date:   Sat, 16 Aug 2014 20:33:24 -0700

Refactor into tty_moveup

Diffstat:
Mfzy.c | 4++--
Mtty.c | 4++++
Mtty.h | 1+
3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/fzy.c b/fzy.c @@ -94,7 +94,7 @@ void clear(tty_t *tty){ while(line++ < NUMLINES + 1){ tty_newline(tty); } - fprintf(tty->fout, "%c%c%iA", 0x1b, '[', line-1); + tty_moveup(tty, line-1); tty_setcol(tty, 0); } @@ -137,7 +137,7 @@ void draw(tty_t *tty){ draw_match(tty, choices[choices_sorted[i]], i == current_selection); line++; } - fprintf(tty->fout, "%c%c%iA", 0x1b, '[', line + 1); + tty_moveup(tty, line + 1); tty_setcol(tty, strlen(prompt) + strlen(search) + 1); fflush(tty->fout); } diff --git a/tty.c b/tty.c @@ -67,6 +67,10 @@ void tty_setcol(tty_t *tty, int col){ tty_printf(tty, "%c%c%iG", 0x1b, '[', col); } +void tty_moveup(tty_t *tty, int i){ + tty_printf(tty, "%c%c%iA", 0x1b, '[', i); +} + void tty_printf(tty_t *tty, const char *fmt, ...){ va_list args; va_start(args, fmt); diff --git a/tty.h b/tty.h @@ -34,6 +34,7 @@ void tty_setnormal(tty_t *tty); */ void tty_newline(tty_t *tty); +void tty_moveup(tty_t *tty, int i); void tty_setcol(tty_t *tty, int col); void tty_printf(tty_t *tty, const char *fmt, ...);