summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-05-12 16:08:49 +0200
committerDave Davenport <qball@gmpclient.org>2017-05-12 16:08:49 +0200
commitc54a817555ed8ac2a2f02805451e7667cbd42d76 (patch)
treeb85e089e889077df3fa3702c27d1a4ddfd653ab9
parentfd56e07159835f691a5b010ae5ed99268291c33b (diff)
If we hit edge of entry box, make left/right move forward to listview.
-rw-r--r--source/view.c12
-rw-r--r--source/widgets/textbox.c18
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, "" );