diff options
author | Quentin Glidic <sardemff7+git@sardemff7.net> | 2016-04-07 15:01:14 +0200 |
---|---|---|
committer | Quentin Glidic <sardemff7+git@sardemff7.net> | 2016-05-07 11:24:10 +0200 |
commit | 5b0964ae32dbed82950efaa3b24ad2af2e4ac86b (patch) | |
tree | 6f4952c01f31fdad04770c1600904331f315cd70 /source/view.c | |
parent | 143acf622b2b7e9051db047c2080095e97d6f995 (diff) |
textbox: Split keybinding and text handling
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Diffstat (limited to 'source/view.c')
-rw-r--r-- | source/view.c | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/source/view.c b/source/view.c index 17a4dbbc..b59c560e 100644 --- a/source/view.c +++ b/source/view.c @@ -1425,35 +1425,44 @@ static void rofi_view_handle_keypress ( RofiViewState *state, xkb_stuff *xkb, xc if ( rofi_view_keyboard_navigation ( state, key, modstate ) ) { return; } - } - int rc = textbox_keypress ( state->text, pad, len, modstate, key ); - // Row is accepted. - if ( rc < 0 ) { - // If a valid item is selected, return that.. - state->selected_line = UINT32_MAX; - if ( state->selected < state->filtered_lines ) { - ( state->selected_line ) = state->line_map[state->selected]; - state->retv = MENU_OK; + int rc = textbox_keybinding ( state->text, modstate, key ); + // Row is accepted. + if ( rc < 0 ) { + // If a valid item is selected, return that.. + state->selected_line = UINT32_MAX; + if ( state->selected < state->filtered_lines ) { + ( state->selected_line ) = state->line_map[state->selected]; + state->retv = MENU_OK; + } + else { + // Nothing entered and nothing selected. + state->retv = MENU_CUSTOM_INPUT; + } + if ( rc == -2 ) { + state->retv |= MENU_CUSTOM_ACTION; + } + + state->quit = TRUE; + return; } - else{ - // Nothing entered and nothing selected. - state->retv = MENU_CUSTOM_INPUT; + // Key press is handled by entry box. + else if ( rc == 1 ) { + state->refilter = TRUE; + state->update = TRUE; + return; } - if ( rc == -2 ) { - state->retv |= MENU_CUSTOM_ACTION; + else if ( rc == 2 ) { + // redraw. + state->update = TRUE; + return; } - - state->quit = TRUE; } - // Key press is handled by entry box. - else if ( rc == 1 ) { + + if ( ( len > 0 ) && ( textbox_keypress ( state->text, pad, len ) ) ) { state->refilter = TRUE; state->update = TRUE; - } - else if ( rc == 2 ) { - // redraw. - state->update = TRUE; + return; } } |