1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2025-02-10 15:44:41 -05:00

Split Custom and Alternate command.

This commit is contained in:
Dave Davenport 2016-06-19 18:02:49 +02:00
parent 341f8322ed
commit 1f4af41e96
10 changed files with 86 additions and 68 deletions

View file

@ -125,7 +125,9 @@ rofi.kb-remove-char-back: BackSpace,Control+h
! Accept entry
rofi.kb-accept-entry: Control+j,Control+m,Return,KP_Enter
! Use entered text as command (in ssh/run modi)
rofi.kb-accept-custom: Control+Return,Shift+Return
rofi.kb-accept-custom: Control+Return
! Use alternate accept command.
rofi.kb-accept-alt: Shift+Return
! Delete entry from history
rofi.kb-delete-entry: Shift+Delete
! Switch to the next mode.

View file

@ -37,6 +37,7 @@ typedef enum
REMOVE_CHAR_BACK,
/** Accept the current selected entry */
ACCEPT_ENTRY,
ACCEPT_ALT,
ACCEPT_CUSTOM,
MODE_NEXT,
MODE_PREVIOUS,

View file

@ -48,7 +48,8 @@ DefaultBinding bindings[NUM_ABE] =
{ .id = REMOVE_CHAR_FORWARD, .name = "kb-remove-char-forward", .keybinding = "Delete,Control+d", .comment = "Delete next char" },
{ .id = REMOVE_CHAR_BACK, .name = "kb-remove-char-back", .keybinding = "BackSpace,Control+h", .comment = "Delete previous char" },
{ .id = ACCEPT_ENTRY, .name = "kb-accept-entry", .keybinding = "Control+j,Control+m,Return,KP_Enter", .comment = "Accept entry" },
{ .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding = "Control+Return,Shift+Return", .comment = "Use entered text as command (in ssh/run modi)" },
{ .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding = "Control+Return", .comment = "Use entered text as command (in ssh/run modi)" },
{ .id = ACCEPT_ALT, .name = "kb-accept-alt", .keybinding = "Shift+Return", .comment = "Use alternate accept command." },
{ .id = DELETE_ENTRY, .name = "kb-delete-entry", .keybinding = "Shift+Delete", .comment = "Delete entry from history" },
{ .id = MODE_NEXT, .name = "kb-mode-next", .keybinding = "Shift+Right,Control+Tab", .comment = "Switch to the next mode." },
{ .id = MODE_PREVIOUS, .name = "kb-mode-previous", .keybinding = "Shift+Left,Control+Shift+Tab", .comment = "Switch to the previous mode." },

View file

@ -589,15 +589,9 @@ int textbox_keybinding ( textbox *tb, KeyBindingAction action )
case REMOVE_CHAR_BACK:
textbox_cursor_bkspc ( tb );
return 1;
case ACCEPT_CUSTOM:
return -2;
case ACCEPT_ENTRY:
return -1;
default:
g_return_val_if_reached ( 0 );
}
g_return_val_if_reached ( 0 );
}
gboolean textbox_append_char ( textbox *tb, char *pad, int pad_len )

View file

@ -947,7 +947,9 @@ static void rofi_view_draw ( RofiViewState *state, cairo_t *d )
if ( list != NULL ) {
pango_attr_list_ref ( list );
}
else{ list = pango_attr_list_new (); }
else{
list = pango_attr_list_new ();
}
token_match_get_pango_attr ( tokens, textbox_get_visible_text ( state->boxes[i] ), list );
textbox_set_pango_attributes ( state->boxes[i], list );
pango_attr_list_unref ( list );
@ -1452,12 +1454,43 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, KeyBindingAction actio
case MOVE_WORD_BACK:
case MOVE_WORD_FORWARD:
case REMOVE_CHAR_BACK:
case ACCEPT_CUSTOM:
case ACCEPT_ENTRY:
{
int rc = textbox_keybinding ( state->text, action );
// Row is accepted.
if ( rc < 0 ) {
if ( rc == 1 ) {
// Entry changed.
state->refilter = TRUE;
state->update = TRUE;
}
else if ( rc == 2 ) {
// Movement.
state->update = TRUE;
}
break;
}
case ACCEPT_ALT:
{
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;
}
state->retv |= MENU_CUSTOM_ACTION;
state->quit = TRUE;
break;
}
case ACCEPT_CUSTOM:
{
state->selected_line = UINT32_MAX;
state->retv = MENU_CUSTOM_INPUT;
state->quit = TRUE;
break;
}
case ACCEPT_ENTRY:
{
// If a valid item is selected, return that..
state->selected_line = UINT32_MAX;
if ( state->selected < state->filtered_lines ) {
@ -1468,21 +1501,8 @@ gboolean rofi_view_trigger_action ( RofiViewState *state, KeyBindingAction actio
// Nothing entered and nothing selected.
state->retv = MENU_CUSTOM_INPUT;
}
if ( rc == -2 ) {
state->retv |= MENU_CUSTOM_ACTION;
}
state->quit = TRUE;
}
// Key press is handled by entry box.
else if ( rc == 1 ) {
state->refilter = TRUE;
state->update = TRUE;
}
else if ( rc == 2 ) {
// redraw.
state->update = TRUE;
}
break;
}
case NUM_ABE: