fzy

terminal fuzzy finder picker

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

commit 819725aa0561da1d1af40c3acf360c7408354b1c
parent 3cb547252a960027fac41cd1c2a98ccdf299ed15
Author: John Hawthorn <john.hawthorn@gmail.com>
Date:   Sat, 16 Aug 2014 20:39:06 -0700

Avoid full clear before redraw

Instead of clearing the existing text before redrawing, clear as we draw
using tty_newline (CSI-K). This looks smoother when scrolling under
xterm and probably other terminals.

Diffstat:
Mfzy.c | 15++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/fzy.c b/fzy.c @@ -120,7 +120,7 @@ void draw_match(tty_t *tty, const char *choice, int selected){ } tty_printf(tty, "%c", choice[i]); } - tty_printf(tty, "\n"); + tty_newline(tty); tty_setnormal(tty); } @@ -131,10 +131,15 @@ void draw(tty_t *tty){ } int line = 0; const char *prompt = "> "; - clear(tty); - tty_printf(tty, "%s%s\n", prompt, search); - for(size_t i = start; line < NUMLINES && i < choices_available; i++){ - draw_match(tty, choices[choices_sorted[i]], i == current_selection); + tty_setcol(tty, 0); + tty_printf(tty, "%s%s", prompt, search); + tty_newline(tty); + for(size_t i = start; line < NUMLINES; i++){ + if(i < choices_available){ + draw_match(tty, choices[choices_sorted[i]], i == current_selection); + }else{ + tty_newline(tty); + } line++; } tty_moveup(tty, line + 1);