mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Rasi patch, allowing special keys, modifying return value.
In dmenu pressing alt-[1-9 will return the selected entry and set the return value to the pressed number.
This commit is contained in:
parent
a974db887a
commit
8d4e1ee8fa
9 changed files with 42 additions and 20 deletions
|
@ -45,21 +45,23 @@ typedef const char * ( *get_display_value )( unsigned int selected_line, void *d
|
|||
typedef enum
|
||||
{
|
||||
/** Entry is selected. */
|
||||
MENU_OK = 0x1,
|
||||
MENU_OK = 0x0010000,
|
||||
/** User canceled the operation. (e.g. pressed escape) */
|
||||
MENU_CANCEL = 0x2,
|
||||
MENU_CANCEL = 0x0020000,
|
||||
/** User requested a mode switch */
|
||||
MENU_NEXT = 0x4,
|
||||
MENU_NEXT = 0x0040000,
|
||||
/** Custom (non-matched) input was entered. */
|
||||
MENU_CUSTOM_INPUT = 0x8,
|
||||
MENU_CUSTOM_INPUT = 0x0080000,
|
||||
/** User wanted to delete entry from history. */
|
||||
MENU_ENTRY_DELETE = 0x10,
|
||||
MENU_ENTRY_DELETE = 0x00100000,
|
||||
/** User wants to jump to another switcher. */
|
||||
MENU_QUICK_SWITCH = 0x20,
|
||||
MENU_QUICK_SWITCH = 0x00200000,
|
||||
/** Go to the previous menu. */
|
||||
MENU_PREVIOUS = 0x40,
|
||||
MENU_PREVIOUS = 0x00400000,
|
||||
/** Modifiers */
|
||||
MENU_SHIFT = 0x1000
|
||||
MENU_SHIFT = 0x10000000,
|
||||
/** Mask */
|
||||
MENU_LOWER_MASK = 0x0000FFFF
|
||||
} MenuReturn;
|
||||
|
||||
|
||||
|
|
|
@ -192,6 +192,19 @@ int dmenu_switcher_dialog ( char **input )
|
|||
}
|
||||
retv = TRUE;
|
||||
}
|
||||
else if ( ( mretv & MENU_QUICK_SWITCH ) ) {
|
||||
if ( number_mode ) {
|
||||
fprintf ( stdout, "%d", selected_line );
|
||||
}
|
||||
else {
|
||||
fputs ( list[selected_line], stdout );
|
||||
}
|
||||
fputc ( '\n', stdout );
|
||||
fflush ( stdout );
|
||||
|
||||
restart = FALSE;
|
||||
retv = -( mretv & MENU_LOWER_MASK ) - 1;
|
||||
}
|
||||
} while ( restart );
|
||||
|
||||
g_strfreev ( list );
|
||||
|
|
|
@ -305,7 +305,7 @@ static SwitcherMode run_mode_result ( int mretv, char **input, unsigned int sele
|
|||
retv = PREVIOUS_DIALOG;
|
||||
}
|
||||
else if ( mretv & MENU_QUICK_SWITCH ) {
|
||||
retv = selected_line;
|
||||
retv = ( mretv & MENU_LOWER_MASK );
|
||||
}
|
||||
else if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line] != NULL ) {
|
||||
exec_cmd ( rmpd->cmd_list[selected_line], shift );
|
||||
|
|
|
@ -131,7 +131,7 @@ static SwitcherMode script_mode_result ( int mretv, char **input, unsigned int s
|
|||
retv = PREVIOUS_DIALOG;
|
||||
}
|
||||
else if ( ( mretv & MENU_QUICK_SWITCH ) ) {
|
||||
retv = selected_line;
|
||||
retv = ( mretv & MENU_LOWER_MASK );
|
||||
}
|
||||
else if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line] != NULL ) {
|
||||
new_list = execute_executor ( sw, rmpd->cmd_list[selected_line], &new_length );
|
||||
|
|
|
@ -295,7 +295,7 @@ static SwitcherMode ssh_mode_result ( int mretv, char **input, unsigned int sele
|
|||
retv = PREVIOUS_DIALOG;
|
||||
}
|
||||
else if ( mretv & MENU_QUICK_SWITCH ) {
|
||||
retv = selected_line;
|
||||
retv = ( mretv & MENU_LOWER_MASK );
|
||||
}
|
||||
else if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line] != NULL ) {
|
||||
exec_ssh ( rmpd->cmd_list[selected_line] );
|
||||
|
|
|
@ -478,8 +478,8 @@ static SwitcherMode window_mode_result ( int mretv, G_GNUC_UNUSED char **input,
|
|||
else if ( mretv & MENU_PREVIOUS ) {
|
||||
retv = PREVIOUS_DIALOG;
|
||||
}
|
||||
else if ( mretv == MENU_QUICK_SWITCH ) {
|
||||
retv = selected_line;
|
||||
else if ( ( mretv & MENU_QUICK_SWITCH ) == MENU_QUICK_SWITCH ) {
|
||||
retv = ( mretv & MENU_LOWER_MASK );
|
||||
}
|
||||
else if ( ( mretv & ( MENU_OK | MENU_CUSTOM_INPUT ) ) && rmpd->cmd_list[selected_line] ) {
|
||||
if ( rmpd->config_i3_mode ) {
|
||||
|
|
|
@ -103,7 +103,7 @@ DefaultBinding bindings[NUM_ABE] =
|
|||
.keybinding = "BackSpace,Control+h",
|
||||
},
|
||||
{
|
||||
.id = ACCEPT_ENTRY,
|
||||
.id = ACCEPT_ENTRY,
|
||||
.name = "kb-accept-entry",
|
||||
.keybinding = "Control+j,Control+m,Return,KP_Enter",
|
||||
},
|
||||
|
|
|
@ -686,8 +686,8 @@ static void menu_mouse_navigation ( MenuState *state, XButtonEvent *xbe )
|
|||
else {
|
||||
for ( unsigned int i = 0; config.sidebar_mode == TRUE && i < num_switchers; i++ ) {
|
||||
if ( switchers[i]->tb->window == ( xbe->window ) ) {
|
||||
*( state->selected_line ) = i;
|
||||
state->retv = MENU_QUICK_SWITCH;
|
||||
*( state->selected_line ) = 0;
|
||||
state->retv = MENU_QUICK_SWITCH | ( i & MENU_LOWER_MASK );
|
||||
state->quit = TRUE;
|
||||
return;
|
||||
}
|
||||
|
@ -1180,9 +1180,13 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom
|
|||
// Switcher short-cut
|
||||
else if ( ( ( ev.xkey.state & Mod1Mask ) == Mod1Mask ) &&
|
||||
key >= XK_1 && key <= XK_9 ) {
|
||||
*( state.selected_line ) = ( key - XK_1 );
|
||||
state.retv = MENU_QUICK_SWITCH;
|
||||
state.quit = TRUE;
|
||||
if ( state.selected < state.filtered_lines ) {
|
||||
*( state.selected_line ) = state.line_map[state.selected];
|
||||
}
|
||||
//*( state.selected_line ) = ( key - XK_1 );
|
||||
unsigned int data = ( key - XK_1 );
|
||||
state.retv = MENU_QUICK_SWITCH | ( data & MENU_LOWER_MASK );
|
||||
state.quit = TRUE;
|
||||
break;
|
||||
}
|
||||
// Special delete entry command.
|
||||
|
@ -1759,6 +1763,9 @@ int main ( int argc, char *argv[] )
|
|||
if ( retv == FALSE ) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
else if ( retv < 0 ) {
|
||||
return -retv;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -243,7 +243,7 @@ int window_send_message ( Display *display, Window target,
|
|||
|
||||
int take_keyboard ( Display *display, Window w )
|
||||
{
|
||||
for ( int i = 0; i < 500; i++) {
|
||||
for ( int i = 0; i < 500; i++ ) {
|
||||
if ( XGrabKeyboard ( display, w, True, GrabModeAsync, GrabModeAsync, CurrentTime ) == GrabSuccess ) {
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue