sled

Једноставни уређивач текста
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 9bcc23ed4c38b0284aeecdc8b56aaa9cf689ab46
родитељ 084ff72a70bbc595fb1d599c098eb41bea505570
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Sun, 20 Feb 2022 21:48:32 +0100

Move processing input_dialog_keys before top_level_keys; minor input dialog UI fixes

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
Msled.c | 69+++++++++++++++++++++++++++++++++++++++++----------------------------
измењених датотека: 1, додавања: 41(+), брисања: 28(-)

diff --git a/sled.c b/sled.c @@ -142,9 +142,11 @@ go_to_line_callback(struct DrawState* state) = state->row - (state->maxy - 2); } free(u8_input); - *state->input = 0; + if (!*state->error) + *state->input = 0; } - state->input_callback = NULL; + if (!*state->error) + state->input_callback = NULL; } void @@ -1063,6 +1065,11 @@ enter_insert_mode(struct DrawState* state) int input_cancel(struct DrawState* state) { + if (*state->error) + { + *state->error = 0; + return 0; + } state->show_input_dialog = 0; *state->input = 0; return 0; @@ -1072,8 +1079,13 @@ int input_enter(struct DrawState* state) { if (state->input_callback) + { state->input_callback(state); - state->show_input_dialog = 0; + if (!*state->error) + state->show_input_dialog = 0; + } + else + state->show_input_dialog = 0; return 0; } @@ -1457,30 +1469,6 @@ handle_key_event(struct tb_event* ev, struct DrawState* state) && !(state->in_command_mode && strchr("jkgG", ev->ch))) state->saved_column = -1; - for (int key = 0; key < LEN(top_level_keys); key++) - { - current = &top_level_keys[key]; - if (((current->ev.key == ev->key) && !ev->ch) - || (current->ev.ch && (current->ev.ch == ev->ch))) - if (current->callback && !current->callback(state)) - return; - } - - if (state->show_help) - { - strcpy(state->error, errors[ERR_DLG_OPEN]); - return; - } - - for (int key = 0; key < LEN(global_keys); key++) - { - current = &global_keys[key]; - if (((current->ev.key == ev->key) && !ev->ch) - || (current->ev.ch && (current->ev.ch == ev->ch))) - if (current->callback && !current->callback(state)) - return; - } - if (state->show_input_dialog) { for (int key = 0; key < LEN(input_dialog_keys); key++) @@ -1506,7 +1494,32 @@ handle_key_event(struct tb_event* ev, struct DrawState* state) return; } } - else if (state->in_command_mode) + + for (int key = 0; key < LEN(top_level_keys); key++) + { + current = &top_level_keys[key]; + if (((current->ev.key == ev->key) && !ev->ch) + || (current->ev.ch && (current->ev.ch == ev->ch))) + if (current->callback && !current->callback(state)) + return; + } + + if (state->show_help) + { + strcpy(state->error, errors[ERR_DLG_OPEN]); + return; + } + + for (int key = 0; key < LEN(global_keys); key++) + { + current = &global_keys[key]; + if (((current->ev.key == ev->key) && !ev->ch) + || (current->ev.ch && (current->ev.ch == ev->ch))) + if (current->callback && !current->callback(state)) + return; + } + + if (state->in_command_mode) { for (int key = 0; key < LEN(command_keys); key++) {