1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-11 13:50:48 -05:00

If we hit edge of entry box, make left/right move forward to listview.

This commit is contained in:
Dave Davenport 2017-05-12 16:08:49 +02:00
parent fd56e07159
commit c54a817555
2 changed files with 24 additions and 6 deletions

View file

@ -1297,7 +1297,19 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, KeyBindingAction actio
break; break;
// If you add a binding here, make sure to add it to textbox_keybinding too // If you add a binding here, make sure to add it to textbox_keybinding too
case MOVE_CHAR_BACK: case MOVE_CHAR_BACK:
{
if ( textbox_keybinding ( state->text, action ) == 0 ) {
listview_nav_left ( state->list_view );
}
break;
}
case MOVE_CHAR_FORWARD: case MOVE_CHAR_FORWARD:
{
if ( textbox_keybinding ( state->text, action ) == 0 ) {
listview_nav_right ( state->list_view );
}
break;
}
case CLEAR_LINE: case CLEAR_LINE:
case MOVE_FRONT: case MOVE_FRONT:
case MOVE_END: case MOVE_END:

View file

@ -405,20 +405,28 @@ void textbox_cursor ( textbox *tb, int pos )
* @param tb Handle to the textbox * @param tb Handle to the textbox
* *
* Move cursor one position forward. * 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 ); textbox_cursor ( tb, tb->cursor + 1 );
return ( old != tb->cursor );
} }
/** /**
* @param tb Handle to the textbox * @param tb Handle to the textbox
* *
* Move cursor one position backward. * 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 ); textbox_cursor ( tb, tb->cursor - 1 );
return ( old != tb->cursor );
} }
// Move word right // Move word right
@ -625,12 +633,10 @@ int textbox_keybinding ( textbox *tb, KeyBindingAction action )
{ {
// Left or Ctrl-b // Left or Ctrl-b
case MOVE_CHAR_BACK: case MOVE_CHAR_BACK:
textbox_cursor_dec ( tb ); return (textbox_cursor_dec ( tb ) == TRUE)?2:0;
return 2;
// Right or Ctrl-F // Right or Ctrl-F
case MOVE_CHAR_FORWARD: case MOVE_CHAR_FORWARD:
textbox_cursor_inc ( tb ); return (textbox_cursor_inc ( tb ) == TRUE)?2:0;
return 2;
// Ctrl-U: Kill from the beginning to the end of the line. // Ctrl-U: Kill from the beginning to the end of the line.
case CLEAR_LINE: case CLEAR_LINE:
textbox_text ( tb, "" ); textbox_text ( tb, "" );