diff options
author | John Hawthorn <john@hawthorn.email> | 2018-09-09 13:05:12 -0700 |
---|---|---|
committer | John Hawthorn <john@hawthorn.email> | 2018-09-09 13:32:10 -0700 |
commit | 757b31309434d7adcd1361be26c1cd2a44d6ec9b (patch) | |
tree | 6fb282e9ae75c879aa9a78695a72c1f9f39a8bce /src | |
parent | 42e9ffd27db2c9634ddc8f82cd736a2caa6728cc (diff) |
Disable line wrap when printing candidates
This solves the line wrapping issue with much simpler code, which also
works better with Unicode characters and when the terminal is resized.
Diffstat (limited to 'src')
-rw-r--r-- | src/tty_interface.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/tty_interface.c b/src/tty_interface.c index a76cfa9..746da4d 100644 --- a/src/tty_interface.c +++ b/src/tty_interface.c @@ -42,15 +42,12 @@ static void draw_match(tty_interface_t *state, const char *choice, int selected) score_t score = match_positions(search, choice, &positions[0]); - size_t maxwidth = tty_getwidth(tty); - - if (options->show_scores && maxwidth >= 9) { + if (options->show_scores) { if (score == SCORE_MIN) { tty_printf(tty, "( ) "); } else { tty_printf(tty, "(%5.2f) ", score); } - maxwidth -= 8; } if (selected) @@ -60,20 +57,17 @@ static void draw_match(tty_interface_t *state, const char *choice, int selected) tty_setinvert(tty); #endif + tty_setnowrap(tty); for (size_t i = 0, p = 0; choice[i] != '\0'; i++) { - if (i + 1 < maxwidth) { - if (positions[p] == i) { - tty_setfg(tty, TTY_COLOR_HIGHLIGHT); - p++; - } else { - tty_setfg(tty, TTY_COLOR_NORMAL); - } - tty_printf(tty, "%c", choice[i]); + if (positions[p] == i) { + tty_setfg(tty, TTY_COLOR_HIGHLIGHT); + p++; } else { - tty_printf(tty, "$"); - break; + tty_setfg(tty, TTY_COLOR_NORMAL); } + tty_printf(tty, "%c", choice[i]); } + tty_setwrap(tty); tty_setnormal(tty); } |