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;
// 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:

View File

@ -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, "" );