From 09e4a64780a442fb32ae6f1ff6c90b865b6fd916 Mon Sep 17 00:00:00 2001 From: Qball Cow Date: Tue, 19 May 2015 19:59:50 +0200 Subject: [PATCH] fix issue #165 --- include/textbox.h | 12 ++++++------ source/dialogs/dmenu.c | 4 ++-- source/rofi.c | 14 ++++++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/include/textbox.h b/include/textbox.h index 1fd2dc33..6ec1cf7b 100644 --- a/include/textbox.h +++ b/include/textbox.h @@ -23,12 +23,12 @@ typedef struct typedef enum { - TB_AUTOHEIGHT = 1 << 0, - TB_AUTOWIDTH = 1 << 1, - TB_LEFT = 1 << 16, - TB_RIGHT = 1 << 17, - TB_CENTER = 1 << 18, - TB_EDITABLE = 1 << 19, + TB_AUTOHEIGHT = 1 << 0, + TB_AUTOWIDTH = 1 << 1, + TB_LEFT = 1 << 16, + TB_RIGHT = 1 << 17, + TB_CENTER = 1 << 18, + TB_EDITABLE = 1 << 19, } TextboxFlags; diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index 9ea5bea9..559ec68c 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -181,7 +181,7 @@ static void dmenu_output_formatted_line ( const char *format, const char *string int dmenu_switcher_dialog ( char **input ) { char *dmenu_prompt = "dmenu "; - int selected_line = 0; + int selected_line = -1; int retv = FALSE; int length = 0; char **list = get_dmenu ( &length ); @@ -223,7 +223,7 @@ int dmenu_switcher_dialog ( char **input ) char *select = NULL; find_arg_str ( "-select", &select ); - if ( select != NULL && find_arg ( "-filter" ) >= 0 ) { + if ( select != NULL /*&& find_arg ( "-filter" ) >= 0 */ ) { char **tokens = tokenize ( select, config.case_sensitive ); int i = 0; for ( i = 0; i < length; i++ ) { diff --git a/source/rofi.c b/source/rofi.c index 2e2b5b60..dd632f0b 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1070,13 +1070,19 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom state.selected = 0; // The cast to unsigned in here is valid, we checked if selected_line > 0. // So its maximum range is 0-2³¹, well within the num_lines range. - if ( ( *( state.selected_line ) ) >= 0 && (unsigned int) ( *( state.selected_line ) ) <= state.num_lines ) { - state.selected = *( state.selected_line ); - } +// if ( ( *( state.selected_line ) ) >= 0 && (unsigned int) ( *( state.selected_line ) ) <= state.num_lines ) { +// state.selected = *( state.selected_line ); +// } state.quit = FALSE; menu_refilter ( &state, lines, mmc, mmc_data, sorting, config.case_sensitive ); + for ( unsigned int i = 0; ( *( state.selected_line ) ) >= 0 && !state.selected && i < state.filtered_lines; i++ ) { + if ( state.line_map[i] == *( state.selected_line ) ) { + state.selected = i; + } + } + int x11_fd = ConnectionNumber ( display ); while ( !state.quit ) { // Update if requested. @@ -1910,7 +1916,7 @@ int main ( int argc, char *argv[] ) SwitcherMode switcher_run ( char **input, Switcher *sw ) { char *prompt = g_strdup_printf ( "%s:", sw->name ); - int selected_line = 0; + int selected_line = -1; unsigned int cmd_list_length = 0; char **cmd_list = NULL;