From f71091204233beeb14cdf6913fde99a4cf84c315 Mon Sep 17 00:00:00 2001 From: QC Date: Tue, 11 Nov 2014 21:50:16 +0100 Subject: [PATCH] Add ctrl-/ as reverse tab. --- Examples/domo_rofi_script.sh | 2 +- doc/generate-manpage.sh | 3 +++ doc/rofi-manpage.markdown | 1 + doc/rofi.1 | 2 ++ include/rofi.h | 9 ++++++--- source/rofi.c | 15 +++++++++++++++ source/run-dialog.c | 3 +++ source/script-dialog.c | 3 +++ source/ssh-dialog.c | 3 +++ 9 files changed, 37 insertions(+), 4 deletions(-) create mode 100755 doc/generate-manpage.sh diff --git a/Examples/domo_rofi_script.sh b/Examples/domo_rofi_script.sh index a66602b8..3a7c33fd 100755 --- a/Examples/domo_rofi_script.sh +++ b/Examples/domo_rofi_script.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -LIGHT_HOST=192.150.0.106 +LIGHT_HOST=192.150.0.113 LIGHT_PORT=8888 prompt() { diff --git a/doc/generate-manpage.sh b/doc/generate-manpage.sh new file mode 100755 index 00000000..b0510bde --- /dev/null +++ b/doc/generate-manpage.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +md2man-roff rofi-manpage.markdown > rofi.1 diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index 81e063d8..aed035f9 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -371,6 +371,7 @@ Rofi supports the following keybindings: * `Ctrl-Page Up`: Go to the previous column * `Ctrl-Page Down`: Go to the next column * `?`: Switch to the next modi. The list can be customized with the `-switchers` argument. +* `ctrl-/`: Switch to the previous modi. The list can be customized with the `-switchers` argument. * `Ctrl-space`: Set selected item as input text. ## FAQ diff --git a/doc/rofi.1 b/doc/rofi.1 index 6217092c..8e1821d0 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -480,6 +480,8 @@ Rofi supports the following keybindings: .IP \(bu 2 \fB\fC?\fR: Switch to the next modi. The list can be customized with the \fB\fC\-switchers\fR argument. .IP \(bu 2 +\fB\fCctrl\-/\fR: Switch to the previous modi. The list can be customized with the \fB\fC\-switchers\fR argument. +.IP \(bu 2 \fB\fCCtrl\-space\fR: Set selected item as input text. .RE .SH FAQ diff --git a/include/rofi.h b/include/rofi.h index 213c825b..5eb74a60 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -15,11 +15,13 @@ extern const char *cache_dir; typedef enum { /** Exit. */ - MODE_EXIT = 1000, + MODE_EXIT = 1000, /** Skip to the next cycle-able dialog. */ - NEXT_DIALOG = 1001, + NEXT_DIALOG = 1001, /** Reload current DIALOG */ - RELOAD_DIALOG = 1002 + RELOAD_DIALOG = 1002, + /** Previous dialog */ + PREVIOUS_DIALOG = 1003 } SwitcherMode; // switcher callback @@ -41,6 +43,7 @@ typedef enum /** User wanted to delete entry from history. */ MENU_ENTRY_DELETE = -4, MENU_QUICK_SWITCH = -5, + MENU_PREVIOUS = -6 } MenuReturn; diff --git a/source/rofi.c b/source/rofi.c index 804d181f..e1fed3e3 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1730,6 +1730,12 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom XA_PRIMARY : netatoms[CLIPBOARD], netatoms[UTF8_STRING], netatoms[UTF8_STRING], main_window, CurrentTime ); } + else if ( ( ( ev.xkey.state & ControlMask ) == ControlMask ) && key == XK_slash ) { + state.retv = MENU_PREVIOUS; + *( state.selected_line ) = 0; + state.quit = TRUE; + break; + } // Menu navigation. else if ( ( ( ev.xkey.state & ShiftMask ) == ShiftMask ) && key == XK_slash ) { @@ -2003,6 +2009,9 @@ SwitcherMode run_switcher_window ( char **input, G_GNUC_UNUSED void *data ) if ( mretv == MENU_NEXT ) { retv = NEXT_DIALOG; } + else if ( mretv == MENU_PREVIOUS ) { + retv = PREVIOUS_DIALOG; + } else if ( mretv == MENU_QUICK_SWITCH ) { retv = selected_line; } @@ -2086,6 +2095,12 @@ static void run_switcher ( int do_fork, SwitcherMode mode ) if ( retv == NEXT_DIALOG ) { mode = ( mode + 1 ) % num_switchers; } + else if ( retv == PREVIOUS_DIALOG ) { + mode = ( mode - 1 ) % num_switchers; + if(mode < 0) { + mode = num_switchers-1; + } + } else if ( retv == RELOAD_DIALOG ) { // do nothing. } diff --git a/source/run-dialog.c b/source/run-dialog.c index d8be65eb..3a41be49 100644 --- a/source/run-dialog.c +++ b/source/run-dialog.c @@ -261,6 +261,9 @@ SwitcherMode run_switcher_dialog ( char **input, G_GNUC_UNUSED void *data ) if ( mretv == MENU_NEXT ) { retv = NEXT_DIALOG; } + else if ( mretv == MENU_PREVIOUS ) { + retv = PREVIOUS_DIALOG; + } else if ( mretv == MENU_QUICK_SWITCH ) { retv = selected_line; } diff --git a/source/script-dialog.c b/source/script-dialog.c index efde4caf..0e6009bd 100644 --- a/source/script-dialog.c +++ b/source/script-dialog.c @@ -127,6 +127,9 @@ SwitcherMode script_switcher_dialog ( char **input, void *data ) if ( mretv == MENU_NEXT ) { retv = NEXT_DIALOG; } + else if ( mretv == MENU_PREVIOUS ) { + retv = PREVIOUS_DIALOG; + } else if ( mretv == MENU_QUICK_SWITCH ) { retv = selected_line; } diff --git a/source/ssh-dialog.c b/source/ssh-dialog.c index 36f34b0e..5de7395d 100644 --- a/source/ssh-dialog.c +++ b/source/ssh-dialog.c @@ -220,6 +220,9 @@ SwitcherMode ssh_switcher_dialog ( char **input, G_GNUC_UNUSED void *data ) if ( mretv == MENU_NEXT ) { retv = NEXT_DIALOG; } + else if ( mretv == MENU_PREVIOUS ) { + retv = PREVIOUS_DIALOG; + } else if ( mretv == MENU_QUICK_SWITCH ) { retv = selected_line; }