diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2014-08-16 20:39:06 -0700 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2014-08-16 20:39:06 -0700 |
commit | 17d5eaee524e62e3604c1c268d3bd13b6609bc1f (patch) | |
tree | 427425dbbc01bec07fb31d4845308733f9053d91 /fzy.c | |
parent | 60307012143bff7ddf59f0d02a4b7ba65df42ee2 (diff) |
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 (limited to 'fzy.c')
-rw-r--r-- | fzy.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -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); |