From 0970c43c3777d68a36b88b895946729a7543029d Mon Sep 17 00:00:00 2001 From: nova Date: Tue, 4 Nov 2025 21:33:34 +0100 Subject: [PATCH] printing of possible bindings now persist through SETTINGS_RELOAD_DIR_DELTA --- interactions.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/interactions.c b/interactions.c index cf939da..1fe5fbc 100644 --- a/interactions.c +++ b/interactions.c @@ -41,7 +41,6 @@ extern char *input; extern time_t *seed; char search_buffer[INPUT_BUFFER_SIZE]; -unsigned int timeout_time = 0; unsigned int input_pass; unsigned long parsed_input_number; yank yank_files = { 0 }; @@ -72,7 +71,6 @@ void user_interactions() { if(ch != ERR) { timeout(10); /* blocking timeout of getch() */ input[input_pass] = ch; - mvaddstr(terminal_height-1, (terminal_width/3)*2, input); input_pass++; if (ch == 27) { /* esc key */ memset(input, ' ', terminal_width); @@ -86,6 +84,7 @@ void user_interactions() { } else { timeout(100); } + mvaddstr(terminal_height-1, (terminal_width/3)*2, input); @@ -101,36 +100,37 @@ void user_interactions() { } input -= number_length; binding_pass = 1; + } - char cmp_len = strlen(input); - if(strlen(input) < 1) { - cmp_len++; - } - for (i = 0; i < binding_count; i++) { + char cmp_len = strlen(input); + if(strlen(input) < 1) { + cmp_len++; + } + for (i = 0; i < binding_count; i++) { + if (strncmp(input + number_length, key_binding[i].key, cmp_len) == 0) { if (strcmp(input + number_length, key_binding[i].key) == 0) { - func_ptr = key_binding[i].func; func_ptr(parsed_input_number, i); - - } else if (strncmp(input + number_length, key_binding[i].key, cmp_len) == 0) { + } else { binding_matches++; mvwprintw(stdscr, terminal_height-binding_matches-1, 0, "\t\t\t"); mvwprintw(stdscr, terminal_height-binding_matches-1, 0, "%s\t%s", key_binding[i].key, key_binding[i].comment); status |= STATUS_INPUT_MATCH; } } - if (status & STATUS_INPUT_MATCH) { - attron(A_UNDERLINE); - mvwprintw(stdscr, terminal_height-binding_matches-2, 0, "input\tcommand\t\t"); - attroff(A_UNDERLINE); - status &= ~STATUS_INPUT_MATCH; - } else if (number_length != strlen(input)) { - memset(input, 0, INPUT_BUFFER_SIZE); - input_pass = 0; - binding_pass = 0; - number_length = 0; - timeout(100); /* blocking timeout of getch() */ - } + } + if (status & STATUS_INPUT_MATCH) { + attron(A_UNDERLINE); + mvwprintw(stdscr, terminal_height-binding_matches-2, 0, "input\tcommand\t\t"); + attroff(A_UNDERLINE); + status &= ~STATUS_INPUT_MATCH; + } else if (number_length != strlen(input)) { + memset(input, 0, INPUT_BUFFER_SIZE); + input_pass = 0; + binding_pass = 0; + number_length = 0; + binding_matches = 0; + timeout(100); /* blocking timeout of getch() */ } } int read_string(WINDOW *win, int y, int x, char *str){