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

keybindings: Merge accept-custom and accept-entry-continue

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
This commit is contained in:
Quentin Glidic 2016-03-17 13:14:30 +01:00
parent c7bc850bb8
commit 20c9abf0a2
10 changed files with 27 additions and 37 deletions

View file

@ -153,7 +153,7 @@ Or get the options from a script:
~/my_script.sh | rofi -dmenu
Pressing `shift-enter` sends the selected entry to STDOUT and moves to the next entry.
Pressing the `accept-custom` binding (`control-enter` or `shift-enter`) sends the selected entry to STDOUT and moves to the next entry.
`-show` *mode*
@ -710,11 +710,13 @@ Shows a list of the windows on the current desktop and allows switching between
### Run
Shows a list of executables in **$PATH** and can launch them (optional in a terminal).
Pressing the `accept-custom` binding (`control-enter` or `shift-enter`) will run the command in a terminal.
### DRun
Same as the **run** launches, but the list is created from the installed desktop files. It automatically launches them
in a terminal if specified in the Desktop File.
Pressing the `accept-custom` binding (`control-enter` or `shift-enter`) with custom input (no entry matching) will run the command in a terminal.
### SSH

View file

@ -198,7 +198,7 @@ Or get the options from a script:
.IP "" 0
.
.P
Pressing \fBshift\-enter\fR sends the selected entry to STDOUT and moves to the next entry\.
Pressing the \fBaccept\-custom\fR binding (\fBcontrol\-enter\fR or \fBshift\-enter\fR) sends the selected entry to STDOUT and moves to the next entry\.
.
.P
\fB\-show\fR \fImode\fR
@ -1154,10 +1154,10 @@ Show a list of all the windows and allow switching between them\.
Shows a list of the windows on the current desktop and allows switching between them\.
.
.SS "Run"
Shows a list of executables in \fB$PATH\fR and can launch them (optional in a terminal)\.
Shows a list of executables in \fB$PATH\fR and can launch them (optional in a terminal)\. Pressing the \fBaccept\-custom\fR binding (\fBcontrol\-enter\fR or \fBshift\-enter\fR) will run the command in a terminal\.
.
.SS "DRun"
Same as the \fBrun\fR launches, but the list is created from the installed desktop files\. It automatically launches them in a terminal if specified in the Desktop File\.
Same as the \fBrun\fR launches, but the list is created from the installed desktop files\. It automatically launches them in a terminal if specified in the Desktop File\. Pressing the \fBaccept\-custom\fR binding (\fBcontrol\-enter\fR or \fBshift\-enter\fR) with custom input (no entry matching) will run the command in a terminal\.
.
.SS "SSH"
Shows a list of SSH targets based on your ssh config file, and allows to quickly ssh into them\.

View file

@ -38,7 +38,6 @@ typedef enum _KeyBindingAction
/** Accept the current selected entry */
ACCEPT_ENTRY,
ACCEPT_CUSTOM,
ACCEPT_ENTRY_CONTINUE,
MODE_NEXT,
MODE_PREVIOUS,
TOGGLE_CASE_SENSITIVITY,

View file

@ -43,8 +43,8 @@ typedef enum
MENU_QUICK_SWITCH = 0x00200000,
/** Go to the previous menu. */
MENU_PREVIOUS = 0x00400000,
/** Modifiers */
MENU_SHIFT = 0x10000000,
/** Bindings specifics */
MENU_CUSTOM_ACTION = 0x10000000,
/** Mask */
MENU_LOWER_MASK = 0x0000FFFF
} MenuReturn;

View file

@ -421,7 +421,7 @@ static void dmenu_finalize ( RofiViewState *state )
// Normal mode
if ( ( mretv & MENU_OK ) && pd->selected_line != UINT32_MAX && cmd_list[pd->selected_line] != NULL ) {
dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], pd->selected_line, input );
if ( ( mretv & MENU_SHIFT ) ) {
if ( ( mretv & MENU_CUSTOM_ACTION ) ) {
restart = TRUE;
int seen = FALSE;
if ( pd->selected_list != NULL ) {
@ -446,7 +446,7 @@ static void dmenu_finalize ( RofiViewState *state )
// Custom input
else if ( ( mretv & ( MENU_CUSTOM_INPUT ) ) ) {
dmenu_output_formatted_line ( pd->format, input, -1, input );
if ( ( mretv & MENU_SHIFT ) ) {
if ( ( mretv & MENU_CUSTOM_ACTION ) ) {
restart = TRUE;
// Move to next line.
pd->selected_line = MIN ( next_pos, cmd_list_length - 1 );

View file

@ -302,7 +302,7 @@ static ModeMode drun_mode_result ( Mode *sw, int mretv, char **input, unsigned i
DRunModePrivateData *rmpd = (DRunModePrivateData *) mode_get_private_data ( sw );
ModeMode retv = MODE_EXIT;
int shift = ( ( mretv & MENU_SHIFT ) == MENU_SHIFT );
gboolean run_in_term = ( ( mretv & MENU_CUSTOM_ACTION ) == MENU_CUSTOM_ACTION );
if ( mretv & MENU_NEXT ) {
retv = NEXT_DIALOG;
@ -317,7 +317,7 @@ static ModeMode drun_mode_result ( Mode *sw, int mretv, char **input, unsigned i
exec_cmd_entry ( &( rmpd->entry_list[selected_line] ) );
}
else if ( ( mretv & MENU_CUSTOM_INPUT ) && *input != NULL && *input[0] != '\0' ) {
exec_cmd ( *input, shift );
exec_cmd ( *input, run_in_term );
}
else if ( ( mretv & MENU_ENTRY_DELETE ) && selected_line < rmpd->cmd_list_length ) {
if ( selected_line < rmpd->history_length ) {

View file

@ -380,7 +380,7 @@ static ModeMode run_mode_result ( Mode *sw, int mretv, char **input, unsigned in
RunModePrivateData *rmpd = (RunModePrivateData *) sw->private_data;
ModeMode retv = MODE_EXIT;
int shift = ( ( mretv & MENU_SHIFT ) == MENU_SHIFT );
gboolean run_in_term = ( ( mretv & MENU_CUSTOM_ACTION ) == MENU_CUSTOM_ACTION );
if ( mretv & MENU_NEXT ) {
retv = NEXT_DIALOG;
@ -392,10 +392,10 @@ static ModeMode run_mode_result ( Mode *sw, int mretv, char **input, unsigned in
retv = ( mretv & MENU_LOWER_MASK );
}
else if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line] != NULL ) {
exec_cmd ( rmpd->cmd_list[selected_line], shift );
exec_cmd ( rmpd->cmd_list[selected_line], run_in_term );
}
else if ( ( mretv & MENU_CUSTOM_INPUT ) && *input != NULL && *input[0] != '\0' ) {
exec_cmd ( *input, shift );
exec_cmd ( *input, run_in_term );
}
else if ( ( mretv & MENU_ENTRY_DELETE ) && rmpd->cmd_list[selected_line] ) {
delete_entry ( rmpd->cmd_list[selected_line] );

View file

@ -46,8 +46,7 @@ DefaultBinding bindings[NUM_ABE] =
{ .id = REMOVE_CHAR_FORWARD, .name = "kb-remove-char-forward", .keybinding = "Delete,Control+d", },
{ .id = REMOVE_CHAR_BACK, .name = "kb-remove-char-back", .keybinding = "BackSpace,Control+h", },
{ .id = ACCEPT_ENTRY, .name = "kb-accept-entry", .keybinding = "Control+j,Control+m,Return,KP_Enter", },
{ .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding = "Control+Return", },
{ .id = ACCEPT_ENTRY_CONTINUE, .name = "kb-accept-entry-continue", .keybinding = "Shift+Return", },
{ .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding = "Control+Return,Shift+Return", },
{ .id = MODE_NEXT, .name = "kb-mode-next", .keybinding = "Shift+Right,Control+Tab" },
{ .id = MODE_PREVIOUS, .name = "kb-mode-previous", .keybinding = "Shift+Left,Control+Shift+Tab" },
{ .id = TOGGLE_CASE_SENSITIVITY, .name = "kb-toggle-case-sensitivity", .keybinding = "grave,dead_grave" },

View file

@ -591,9 +591,6 @@ int textbox_keypress ( textbox *tb, char *pad, int pad_len, unsigned int modstat
else if ( abe_test_action ( ACCEPT_CUSTOM, modstate, key ) ) {
return -2;
}
else if ( abe_test_action ( ACCEPT_ENTRY_CONTINUE, modstate, key ) ) {
return -3;
}
else if ( abe_test_action ( ACCEPT_ENTRY, modstate, key ) ) {
return -1;
}

View file

@ -1411,25 +1411,18 @@ static void rofi_view_mainloop_iter ( RofiViewState *state, xcb_generic_event_t
int rc = textbox_keypress ( state->text, pad, len, modstate, key );
// Row is accepted.
if ( rc < 0 ) {
int shift = ( ( xkpe->state & ShiftMask ) == ShiftMask );
// If a valid item is selected, return that..
state->selected_line = UINT32_MAX;
if ( state->selected < state->filtered_lines ) {
( state->selected_line ) = state->line_map[state->selected];
if ( strlen ( state->text->text ) > 0 && rc == -2 ) {
state->retv = MENU_CUSTOM_INPUT;
}
else {
state->retv = MENU_OK;
}
}
else{
// Nothing entered and nothing selected.
state->retv = MENU_CUSTOM_INPUT;
}
if ( shift ) {
state->retv |= MENU_SHIFT;
if ( rc == -2 ) {
state->retv |= MENU_CUSTOM_ACTION;
}
state->quit = TRUE;