From 21235b0600783173c5cd0849a637edeeab862838 Mon Sep 17 00:00:00 2001 From: qedi Date: Fri, 28 Nov 2014 22:24:07 -0500 Subject: [PATCH 1/2] Force custom commandline when Ctrl-Return is used --- source/rofi.c | 6 +++++- source/textbox.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/source/rofi.c b/source/rofi.c index 2d8454a4..b2efb1fd 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1650,10 +1650,14 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom } // If a valid item is selected, return that.. - if ( state.selected < state.filtered_lines && state.filtered[state.selected] != NULL ) { + if ( rc != -2 + && state.selected < state.filtered_lines && state.filtered[state.selected] != NULL ) { state.retv = MENU_OK; *( state.selected_line ) = state.line_map[state.selected]; } + // Either: + // Ctrl+Enter was used to force using custom input (-2) + // or // No item selected, but user entered something else if ( strlen ( state.text->text ) > 0 ) { state.retv = MENU_CUSTOM_INPUT; diff --git a/source/textbox.c b/source/textbox.c index 3cbcb293..fcfe8340 100644 --- a/source/textbox.c +++ b/source/textbox.c @@ -405,6 +405,9 @@ int textbox_keypress ( textbox *tb, XEvent *ev ) textbox_cursor_bkspc ( tb ); return 1; } + else if ( ( ev->xkey.state & ControlMask ) && key == XK_Return || key == XK_KP_Enter ) { + return -2; + } else if ( key == XK_Return || key == XK_KP_Enter || ( ( ev->xkey.state & ControlMask ) && key == XK_j ) || ( ( ev->xkey.state & ControlMask ) && key == XK_m ) ) { From ada9f81ce0f0cce95e1ec361aa520ee39509d3f4 Mon Sep 17 00:00:00 2001 From: qedi Date: Sat, 29 Nov 2014 09:39:27 -0500 Subject: [PATCH 2/2] fix logic for Ctrl+Return/Ctrl+Enter --- source/textbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/textbox.c b/source/textbox.c index fcfe8340..5228672f 100644 --- a/source/textbox.c +++ b/source/textbox.c @@ -405,7 +405,7 @@ int textbox_keypress ( textbox *tb, XEvent *ev ) textbox_cursor_bkspc ( tb ); return 1; } - else if ( ( ev->xkey.state & ControlMask ) && key == XK_Return || key == XK_KP_Enter ) { + else if ( ( ev->xkey.state & ControlMask ) && ( key == XK_Return || key == XK_KP_Enter) ) { return -2; } else if ( key == XK_Return || key == XK_KP_Enter ||