Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ void tty_setwrap(tty_t *tty) {
tty_printf(tty, "%c%c?7h", 0x1b, '[');
}

void tty_hidecursor(tty_t *tty) {
tty_printf(tty, "\x1b[" "?25l");
}

void tty_showcursor(tty_t *tty) {
tty_printf(tty, "\x1b[" "?25h");
}

void tty_newline(tty_t *tty) {
tty_printf(tty, "%c%cK\n", 0x1b, '[');
}
Expand Down
3 changes: 3 additions & 0 deletions src/tty.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ void tty_setnormal(tty_t *tty);
void tty_setnowrap(tty_t *tty);
void tty_setwrap(tty_t *tty);

void tty_hidecursor(tty_t *tty);
void tty_showcursor(tty_t *tty);

#define TTY_COLOR_BLACK 0
#define TTY_COLOR_RED 1
#define TTY_COLOR_GREEN 2
Expand Down
4 changes: 3 additions & 1 deletion src/tty_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ static void draw(tty_interface_t *state) {
}
}

tty_hidecursor(tty);
tty_setcol(tty, 0);
tty_printf(tty, "%s%s", options->prompt, state->search);
tty_clearline(tty);
Expand All @@ -102,11 +103,11 @@ 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);
if (choice) {
draw_match(state, choice, i == choices->selection);
}
tty_clearline(tty);
}

if (num_lines + options->show_info)
Expand All @@ -117,6 +118,7 @@ static void draw(tty_interface_t *state) {
for (size_t i = 0; i < state->cursor; i++)
fputc(state->search[i], tty->fout);
tty_flush(tty);
tty_showcursor(tty);
}

static void update_search(tty_interface_t *state) {
Expand Down