diff --git a/Changelog b/Changelog index bffe9c8d..38e3a55b 100644 --- a/Changelog +++ b/Changelog @@ -10,6 +10,7 @@ - Dmenu can read from file instead of stdin. - Regex matching (#113) - Take Screenshot of rofi using keybinding. + - Hotkey for sorting: (#298) Improvements: - Fix return code of multi-select. - Update manpage (#289, #291) diff --git a/README.md b/README.md index e6d1e224..0275384f 100644 --- a/README.md +++ b/README.md @@ -155,6 +155,7 @@ Type `Shift-Right` to switch from Window list mode to Run mode and back. |`Ctrl-space` | Set selected item as input text. | |`Shift-Del` | Delete entry from history. | |`grave` | Toggle case sensitivity. | +|`Alt-grave` | Toggle levenshtein sort. | |`Alt-Shift-S` | Take a screenshot and store this in the Pictures directory. | diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index 05666643..3076459a 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -779,6 +779,7 @@ The first two fields specify the alpha level. This determines the amount of tran * `Ctrl-space`: Set selected item as input text. * `Shift-Del`: Delete entry from history. * `grave`: Toggle case sensitivity. + * `Alt-grave`: Toggle levenshtein sorting. * `Alt-Shift-S`: Take a screenshot and store this in the Pictures directory. To get a full list of keybindings, see `rofi -dump-xresources | grep kb-`. diff --git a/doc/rofi.1 b/doc/rofi.1 index eb2930ff..07ef4609 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -1300,6 +1300,9 @@ The first two fields specify the alpha level\. This determines the amount of tra \fBgrave\fR: Toggle case sensitivity\. . .IP "\(bu" 4 +\fBAlt\-grave\fR: Toggle levenshtein sorting\. +. +.IP "\(bu" 4 \fBAlt\-Shift\-S\fR: Take a screenshot and store this in the Pictures directory\. . .IP "" 0 diff --git a/include/keyb.h b/include/keyb.h index 86fe5de7..4432a12f 100644 --- a/include/keyb.h +++ b/include/keyb.h @@ -54,6 +54,7 @@ typedef enum _KeyBindingAction CUSTOM_18, CUSTOM_19, SCREENSHOT, + TOGGLE_SORT, NUM_ABE } KeyBindingAction; diff --git a/source/keyb.c b/source/keyb.c index 3d0c0ede..03c4a143 100644 --- a/source/keyb.c +++ b/source/keyb.c @@ -84,7 +84,8 @@ DefaultBinding bindings[NUM_ABE] = { .id = CUSTOM_18, .name = "kb-custom-18", .keybinding = "Alt+Shift+8" }, { .id = CUSTOM_17, .name = "kb-custom-17", .keybinding = "Alt+Shift+7" }, { .id = CUSTOM_19, .name = "kb-custom-19", .keybinding = "Alt+Shift+9" }, - { .id = SCREENSHOT, .name = "kb-screenshot", .keybinding = "Alt+Shift+S" }, + { .id = SCREENSHOT, .name = "kb-screenshot", .keybinding = "Alt+Shift+S" }, + { .id = TOGGLE_SORT, .name = "kb-toggle-sort", .keybinding = "Alt+grave" }, }; void setup_abe ( void ) diff --git a/source/rofi.c b/source/rofi.c index 12326e9a..4e84a53b 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1390,9 +1390,7 @@ MenuReturn menu ( Mode *sw, char **input, char *prompt, unsigned int *selected_l scrollbar_set_max_value ( state.scrollbar, state.num_lines ); // filtered list state.line_map = g_malloc0_n ( state.num_lines, sizeof ( unsigned int ) ); - if ( config.levenshtein_sort ) { - state.distance = (int *) g_malloc0_n ( state.num_lines, sizeof ( int ) ); - } + state.distance = (int *) g_malloc0_n ( state.num_lines, sizeof ( int ) ); // resize window vertically to suit // Subtract the margin of the last row. @@ -1565,6 +1563,12 @@ MenuReturn menu ( Mode *sw, char **input, char *prompt, unsigned int *selected_l menu_capture_screenshot ( ); break; } + if ( abe_test_action ( TOGGLE_SORT, ev.xkey.state, key ) ) { + config.levenshtein_sort = !config.levenshtein_sort; + state.refilter = TRUE; + state.update = TRUE; + break; + } else if ( abe_test_action ( MODE_PREVIOUS, ev.xkey.state, key ) ) { state.retv = MENU_PREVIOUS; *( state.selected_line ) = 0;