summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Glidic <sardemff7+git@sardemff7.net>2016-03-17 13:14:30 +0100
committerQuentin Glidic <sardemff7+git@sardemff7.net>2016-03-20 10:39:34 +0100
commit20c9abf0a2ef3072453b92db71ad259fd008e27a (patch)
treefaa9a30fce30b4adaa0a9b4aa25f7c6d9dfb465e
parentc7bc850bb8936944311e4a391ae2ade100e8948d (diff)
keybindings: Merge accept-custom and accept-entry-continue
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
-rw-r--r--doc/rofi-manpage.markdown4
-rw-r--r--doc/rofi.16
-rw-r--r--include/keyb.h1
-rw-r--r--include/mode.h20
-rw-r--r--source/dialogs/dmenu.c4
-rw-r--r--source/dialogs/drun.c4
-rw-r--r--source/dialogs/run.c6
-rw-r--r--source/keyb.c3
-rw-r--r--source/textbox.c3
-rw-r--r--source/view.c13
10 files changed, 27 insertions, 37 deletions
diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown
index 828a03f2..ba59b100 100644
--- a/doc/rofi-manpage.markdown
+++ b/doc/rofi-manpage.markdown
@@ -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
diff --git a/doc/rofi.1 b/doc/rofi.1
index 4d5d8a9d..9afda3a5 100644
--- a/doc/rofi.1
+++ b/doc/rofi.1
@@ -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\.
diff --git a/include/keyb.h b/include/keyb.h
index 9c986db9..ad3b049d 100644
--- a/include/keyb.h
+++ b/include/keyb.h
@@ -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,
diff --git a/include/mode.h b/include/mode.h
index ebb8f224..fd899a56 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -30,23 +30,23 @@ typedef enum
typedef enum
{
/** Entry is selected. */
- MENU_OK = 0x00010000,
+ MENU_OK = 0x00010000,
/** User canceled the operation. (e.g. pressed escape) */
- MENU_CANCEL = 0x00020000,
+ MENU_CANCEL = 0x00020000,
/** User requested a mode switch */
- MENU_NEXT = 0x00040000,
+ MENU_NEXT = 0x00040000,
/** Custom (non-matched) input was entered. */
- MENU_CUSTOM_INPUT = 0x00080000,
+ MENU_CUSTOM_INPUT = 0x00080000,
/** User wanted to delete entry from history. */
- MENU_ENTRY_DELETE = 0x00100000,
+ MENU_ENTRY_DELETE = 0x00100000,
/** User wants to jump to another switcher. */
- MENU_QUICK_SWITCH = 0x00200000,
+ MENU_QUICK_SWITCH = 0x00200000,
/** Go to the previous menu. */
- MENU_PREVIOUS = 0x00400000,
- /** Modifiers */
- MENU_SHIFT = 0x10000000,
+ MENU_PREVIOUS = 0x00400000,
+ /** Bindings specifics */
+ MENU_CUSTOM_ACTION = 0x10000000,
/** Mask */
- MENU_LOWER_MASK = 0x0000FFFF
+ MENU_LOWER_MASK = 0x0000FFFF
} MenuReturn;
/**
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c
index 4f87bcc2..b36a581d 100644
--- a/source/dialogs/dmenu.c
+++ b/source/dialogs/dmenu.c
@@ -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 );
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c
index 9a19c0b6..e5757bd9 100644
--- a/source/dialogs/drun.c
+++ b/source/dialogs/drun.c
@@ -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 ) {
diff --git a/source/dialogs/run.c b/source/dialogs/run.c
index f8efb5e4..4b452b09 100644
--- a/source/dialogs/run.c
+++ b/source/dialogs/run.c
@@ -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] );
diff --git a/source/keyb.c b/source/keyb.c
index 972dd0c3..87c7936a 100644
--- a/source/keyb.c
+++ b/source/keyb.c
@@ -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" },
diff --git a/source/textbox.c b/source/textbox.c
index 1262d56b..43059a76 100644
--- a/source/textbox.c
+++ b/source/textbox.c
@@ -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;
}
diff --git a/source/view.c b/source/view.c
index 812d8dff..318bca39 100644
--- a/source/view.c
+++ b/source/view.c
@@ -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;
- }
+ 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;