summaryrefslogtreecommitdiff
path: root/src/tty_interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tty_interface.c')
-rw-r--r--src/tty_interface.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/tty_interface.c b/src/tty_interface.c
index 343dde8..305c0eb 100644
--- a/src/tty_interface.c
+++ b/src/tty_interface.c
@@ -103,7 +103,7 @@ static void draw(tty_interface_t *state) {
for (size_t i = start; i < start + num_lines; i++) {
tty_printf(tty, "\n");
tty_clearline(tty);
- const char *choice = choices_get(choices, i);
+ const char *choice = choices_get_search(choices, i);
if (choice) {
draw_match(state, choice, i == choices->selection);
}
@@ -140,10 +140,11 @@ static void action_emit(tty_interface_t *state) {
/* ttyout should be flushed before outputting on stdout */
tty_close(state->tty);
- const char *selection = choices_get(state->choices, state->choices->selection);
+ char *selection = choices_get_output(state->choices, state->choices->selection);
if (selection) {
/* output the selected result */
printf("%s\n", selection);
+ free(selection);
} else {
/* No match, output the query instead */
printf("%s\n", state->search);
@@ -237,9 +238,9 @@ static void action_pagedown(tty_interface_t *state) {
static void action_autocomplete(tty_interface_t *state) {
update_state(state);
- const char *current_selection = choices_get(state->choices, state->choices->selection);
+ const char *current_selection = choices_get_search(state->choices, state->choices->selection);
if (current_selection) {
- strncpy(state->search, choices_get(state->choices, state->choices->selection), SEARCH_SIZE_MAX);
+ strncpy(state->search, choices_get_search(state->choices, state->choices->selection), SEARCH_SIZE_MAX);
state->cursor = strlen(state->search);
}
}