From 6a38f88e98ea584c429a6c47c06c55afc5f9b941 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 8 Sep 2020 18:24:36 +0200 Subject: [PATCH] Split MENU_QUICK_SWITCH into MENU_CUSTOM_COMMAND/QUICK_SWITCH --- include/mode.h | 2 ++ source/dialogs/dmenu.c | 6 +++--- source/dialogs/script.c | 17 ++++++++++++++++- source/view.c | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/include/mode.h b/include/mode.h index ab3c6095..5969ef8e 100644 --- a/include/mode.h +++ b/include/mode.h @@ -77,6 +77,8 @@ typedef enum MENU_ENTRY_DELETE = 0x00100000, /** User wants to jump to another switcher. */ MENU_QUICK_SWITCH = 0x00200000, + /** User wants to jump to custom command. */ + MENU_CUSTOM_COMMAND= 0x00800000, /** Go to the previous menu. */ MENU_PREVIOUS = 0x00400000, /** Bindings specifics */ diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index 65235710..896ce863 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -575,14 +575,14 @@ static void dmenu_finalize ( RofiViewState *state ) rofi_view_set_overlay ( state, NULL ); } } - else if ( ( mretv & ( MENU_OK | MENU_QUICK_SWITCH ) ) && cmd_list[pd->selected_line].entry != NULL ) { + else if ( ( mretv & ( MENU_OK | MENU_CUSTOM_COMMAND ) ) && cmd_list[pd->selected_line].entry != NULL ) { if ( cmd_list[pd->selected_line].nonselectable == TRUE ) { g_free ( input ); return; } dmenu_print_results ( pd, input ); retv = TRUE; - if ( ( mretv & MENU_QUICK_SWITCH ) ) { + if ( ( mretv & MENU_CUSTOM_COMMAND ) ) { retv = 10 + ( mretv & MENU_LOWER_MASK ); } g_free ( input ); @@ -640,7 +640,7 @@ static void dmenu_finalize ( RofiViewState *state ) retv = TRUE; } // Quick switch with entry selected. - else if ( ( mretv & MENU_QUICK_SWITCH ) ) { + else if ( ( mretv & MENU_CUSTOM_COMMAND ) ) { dmenu_print_results ( pd, input ); restart = FALSE; diff --git a/source/dialogs/script.c b/source/dialogs/script.c index 3f02e170..45b94954 100644 --- a/source/dialogs/script.c +++ b/source/dialogs/script.c @@ -278,7 +278,22 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned DmenuScriptEntry *new_list = NULL; unsigned int new_length = 0; - if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line].entry != NULL ) { + if ( ( mretv & MENU_CUSTOM_COMMAND ) ) { + //retv = 1+( mretv & MENU_LOWER_MASK ); + script_mode_reset_highlight ( sw ); + if ( selected_line != UINT32_MAX ) { + new_list = execute_executor ( sw, rmpd->cmd_list[selected_line].entry, &new_length, 10 + ( mretv & MENU_LOWER_MASK ), &( rmpd->cmd_list[selected_line] ) ); + } + else { + if ( rmpd->no_custom == FALSE ) { + new_list = execute_executor ( sw, *input, &new_length, 10 + ( mretv & MENU_LOWER_MASK ), NULL ); + } + else { + return RELOAD_DIALOG; + } + } + } + else if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line].entry != NULL ) { if ( rmpd->cmd_list[selected_line].nonselectable ) { return RELOAD_DIALOG; } diff --git a/source/view.c b/source/view.c index 1be752c1..44ce9328 100644 --- a/source/view.c +++ b/source/view.c @@ -1300,7 +1300,7 @@ static void rofi_view_trigger_global_action ( KeyBindingAction action ) if ( selected < state->filtered_lines ) { ( state->selected_line ) = state->line_map[selected]; } - state->retv = MENU_QUICK_SWITCH | ( ( action - CUSTOM_1 ) & MENU_LOWER_MASK ); + state->retv = MENU_CUSTOM_COMMAND | ( ( action - CUSTOM_1 ) & MENU_LOWER_MASK ); state->quit = TRUE; break; }