diff options
author | John Hawthorn <john.hawthorn@gmail.com> | 2016-06-27 01:14:44 -0700 |
---|---|---|
committer | John Hawthorn <john.hawthorn@gmail.com> | 2016-07-10 13:03:25 -0700 |
commit | 7d3b5c1fd8a78936beaee22f87d675ebdf0239d2 (patch) | |
tree | 75c35d6feaaba58c3d85defd7c2ad61bb9b4b494 | |
parent | 5c2d67ca7a14cfad94a5718ea62ad1b4d31f73b6 (diff) |
Use score_t instead of double
-rw-r--r-- | src/choices.c | 2 | ||||
-rw-r--r-- | src/choices.h | 6 | ||||
-rw-r--r-- | src/tty_interface.c | 11 |
3 files changed, 13 insertions, 6 deletions
diff --git a/src/choices.c b/src/choices.c index c935067..14712fd 100644 --- 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 index 319765e..f5f9892 100644 --- 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 index eddd510..0f33305 100644 --- 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); |