fzy
terminal fuzzy finder picker
git clone https://9o.is/git/fzy.git
commit d50465cbfed201a4836a6a947776fe8007557a9e parent 350d51de00c1616774aab2504343e3b35c881032 Author: Jul <jul@9o.is> Date: Tue, 5 Aug 2025 02:50:21 -0400 center scrolling Diffstat:
| M | src/options.c | | | 1 | - |
| M | src/options.h | | | 1 | - |
| M | src/tty_interface.c | | | 5 | +++-- |
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/options.c b/src/options.c @@ -47,7 +47,6 @@ void options_init(options_t *options) { options->filter = NULL; options->init_search = NULL; options->show_scores = 0; - options->scrolloff = 1; options->tty_filename = DEFAULT_TTY; options->num_lines = DEFAULT_NUM_LINES; options->prompt = DEFAULT_PROMPT; diff --git a/src/options.h b/src/options.h @@ -12,7 +12,6 @@ typedef struct { const char *tty_filename; int show_scores; unsigned int num_lines; - unsigned int scrolloff; const char *prompt; unsigned int workers; char input_delimiter; diff --git a/src/tty_interface.c b/src/tty_interface.c @@ -82,9 +82,10 @@ static void draw(tty_interface_t *state) { unsigned int num_lines = options->num_lines; size_t start = 0; + size_t scroll_threshold = (num_lines / 2) + 1; size_t current_selection = choices->selection; - if (current_selection + options->scrolloff >= num_lines) { - start = current_selection + options->scrolloff - num_lines + 1; + if (current_selection >= scroll_threshold) { + start = current_selection - scroll_threshold + 1; size_t available = choices_available(choices); if (start + num_lines >= available && available > 0) { start = available - num_lines;