fzy
terminal fuzzy finder picker
git clone https://9o.is/git/fzy.git
commit 893590fd1506d55c94568d3d3bcfada3819a1277 parent 1c048ebae35f579959a95457090a2c957f4a3f58 Author: John Hawthorn <john.hawthorn@gmail.com> Date: Mon, 27 Jun 2016 01:14:44 -0700 Use score_t instead of double Diffstat:
| M | src/choices.c | | | 2 | +- |
| M | src/choices.h | | | 6 | ++++-- |
| M | src/tty_interface.c | | | 11 | ++++++++--- |
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/choices.c b/src/choices.c @@ -216,7 +216,7 @@ const char *choices_get(choices_t *c, size_t n) { } } -double choices_getscore(choices_t *c, size_t n) { +score_t choices_getscore(choices_t *c, size_t n) { return c->results[n].score; } diff --git a/src/choices.h b/src/choices.h @@ -3,8 +3,10 @@ #include <stdio.h> +#include "match.h" + struct scored_result { - double score; + score_t score; const char *str; }; @@ -31,7 +33,7 @@ void choices_add(choices_t *c, const char *choice); size_t choices_available(choices_t *c); void choices_search(choices_t *c, const char *search); const char *choices_get(choices_t *c, size_t n); -double choices_getscore(choices_t *c, size_t n); +score_t choices_getscore(choices_t *c, size_t n); void choices_prev(choices_t *c); void choices_next(choices_t *c); diff --git a/src/tty_interface.c b/src/tty_interface.c @@ -30,12 +30,17 @@ static void draw_match(tty_interface_t *state, const char *choice, int selected) for (int i = 0; i < n + 1; i++) positions[i] = -1; - double score = match_positions(search, choice, &positions[0]); + score_t score = match_positions(search, choice, &positions[0]); size_t maxwidth = tty_getwidth(tty); - if (options->show_scores) - tty_printf(tty, "(%5.2f) ", score); + if (options->show_scores) { + if (score == SCORE_MIN) { + tty_printf(tty, "( ) "); + } else { + tty_printf(tty, "(%5.2f) ", score); + } + } if (selected) tty_setinvert(tty);