From c54a817555ed8ac2a2f02805451e7667cbd42d76 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 12 May 2017 16:08:49 +0200 Subject: [PATCH] If we hit edge of entry box, make left/right move forward to listview. --- source/view.c | 12 ++++++++++++ source/widgets/textbox.c | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/source/view.c b/source/view.c index 771627da..9c74a0cc 100644 --- a/source/view.c +++ b/source/view.c @@ -1297,7 +1297,19 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, KeyBindingAction actio break; // If you add a binding here, make sure to add it to textbox_keybinding too case MOVE_CHAR_BACK: + { + if ( textbox_keybinding ( state->text, action ) == 0 ) { + listview_nav_left ( state->list_view ); + } + break; + } case MOVE_CHAR_FORWARD: + { + if ( textbox_keybinding ( state->text, action ) == 0 ) { + listview_nav_right ( state->list_view ); + } + break; + } case CLEAR_LINE: case MOVE_FRONT: case MOVE_END: diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index e3f3b9be..32f38330 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -405,20 +405,28 @@ void textbox_cursor ( textbox *tb, int pos ) * @param tb Handle to the textbox * * Move cursor one position forward. + * + * @returns if cursor was moved. */ -static void textbox_cursor_inc ( textbox *tb ) +static int textbox_cursor_inc ( textbox *tb ) { + int old = tb->cursor; textbox_cursor ( tb, tb->cursor + 1 ); + return ( old != tb->cursor ); } /** * @param tb Handle to the textbox * * Move cursor one position backward. + * + * @returns if cursor was moved. */ -static void textbox_cursor_dec ( textbox *tb ) +static int textbox_cursor_dec ( textbox *tb ) { + int old = tb->cursor; textbox_cursor ( tb, tb->cursor - 1 ); + return ( old != tb->cursor ); } // Move word right @@ -625,12 +633,10 @@ int textbox_keybinding ( textbox *tb, KeyBindingAction action ) { // Left or Ctrl-b case MOVE_CHAR_BACK: - textbox_cursor_dec ( tb ); - return 2; + return (textbox_cursor_dec ( tb ) == TRUE)?2:0; // Right or Ctrl-F case MOVE_CHAR_FORWARD: - textbox_cursor_inc ( tb ); - return 2; + return (textbox_cursor_inc ( tb ) == TRUE)?2:0; // Ctrl-U: Kill from the beginning to the end of the line. case CLEAR_LINE: textbox_text ( tb, "" );