From 5ddcac2514cd1ed8218a0688909cdf6dd2571474 Mon Sep 17 00:00:00 2001 From: QC Date: Sun, 3 Aug 2014 17:05:06 +0200 Subject: [PATCH] Cleanup previous test commit. --- include/rofi.h | 2 +- source/dmenu-dialog.c | 5 +---- source/rofi.c | 12 +++++++----- source/run-dialog.c | 3 ++- source/script-dialog.c | 2 +- source/ssh-dialog.c | 3 ++- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/rofi.h b/include/rofi.h index 356e0f00..b639eb21 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -80,7 +80,7 @@ typedef int ( *menu_match_cb )( char **tokens, const char *input, int index, voi MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prompt, Time *time, int *shift, menu_match_cb mmc, void *mmc_data, - int *selected_line ) __attribute__ ( ( nonnull ( 1, 3, 4, 9 ) ) ); + int *selected_line, int sorting ) __attribute__ ( ( nonnull ( 1, 3, 4, 9 ) ) ); void catch_exit ( __attribute__( ( unused ) ) int sig ); diff --git a/source/dmenu-dialog.c b/source/dmenu-dialog.c index ff604db2..8fd77311 100644 --- a/source/dmenu-dialog.c +++ b/source/dmenu-dialog.c @@ -73,13 +73,10 @@ SwitcherMode dmenu_switcher_dialog ( char **input, void *data ) char **list = get_dmenu ( &length ); int restart = FALSE; - // Force off sorting. (TODO: should be an argument to menu, and not hacking the user config.) - config.levenshtein_sort = FALSE; - do { int shift = 0; int mretv = menu ( list, length, input, dmenu_prompt, NULL, &shift, - token_match, NULL, &selected_line ); + token_match, NULL, &selected_line, FALSE ); // We normally do not want to restart the loop. restart = FALSE; diff --git a/source/rofi.c b/source/rofi.c index 60cfe8e3..f75d50b5 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1061,7 +1061,7 @@ static void calculate_window_position ( const workarea *mon, int *x, int *y, int } MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prompt, Time *time, - int *shift, menu_match_cb mmc, void *mmc_data, int *selected_line ) + int *shift, menu_match_cb mmc, void *mmc_data, int *selected_line , int sorting) { int retv = MENU_CANCEL; unsigned int i, j; @@ -1184,7 +1184,7 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom char **filtered = calloc ( num_lines, sizeof ( char* ) ); int *line_map = calloc ( num_lines, sizeof ( int ) ); int *distance = NULL; - if ( config.levenshtein_sort ) { + if ( sorting ) { distance = calloc ( num_lines, sizeof ( int ) ); } unsigned int filtered_lines = 0; @@ -1231,10 +1231,11 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom // If each token was matched, add it to list. if ( match ) { line_map[j] = i; - if ( config.levenshtein_sort ) { + if ( sorting ) { distance[i] = levenshtein ( text->text, lines[i] ); } // Try to look-up the selected line and highlight that. + // This is needed 'hack' to fix the dmenu 'next row' modi. if(init == 0 && selected_line != NULL && (*selected_line) == i) { selected = j; init = 1; @@ -1242,7 +1243,7 @@ MenuReturn menu ( char **lines, unsigned int num_lines, char **input, char *prom j++; } } - if ( config.levenshtein_sort ) { + if ( sorting ) { qsort_r ( line_map, j, sizeof ( int ), lev_sort, distance ); } // Update the filtered list. @@ -1675,7 +1676,8 @@ SwitcherMode run_switcher_window ( char **input, void *data ) } Time time; int selected_line = 0; - MenuReturn mretv = menu ( list, lines, input, "window:", &time, NULL, window_match, ids, &selected_line ); + MenuReturn mretv = menu ( list, lines, input, "window:", &time, NULL, + window_match, ids, &selected_line, config.levenshtein_sort ); if ( mretv == MENU_NEXT ) { retv = NEXT_DIALOG; diff --git a/source/run-dialog.c b/source/run-dialog.c index 8dc630fe..c029007f 100644 --- a/source/run-dialog.c +++ b/source/run-dialog.c @@ -213,7 +213,8 @@ SwitcherMode run_switcher_dialog ( char **input, void *data ) cmd_list[1] = NULL; } - int mretv = menu ( cmd_list, cmd_list_length, input, "run:", NULL, &shift, token_match, NULL, &selected_line ); + int mretv = menu ( cmd_list, cmd_list_length, input, "run:", + NULL, &shift, token_match, NULL, &selected_line, config.levenshtein_sort ); if ( mretv == MENU_NEXT ) { retv = NEXT_DIALOG; diff --git a/source/script-dialog.c b/source/script-dialog.c index 6897e02d..a6eb78e2 100644 --- a/source/script-dialog.c +++ b/source/script-dialog.c @@ -134,7 +134,7 @@ SwitcherMode script_switcher_dialog ( char **input, void *data ) unsigned int new_length = 0; char **new_list = NULL; int mretv = menu ( list, length, input, prompt, NULL, NULL, - token_match, NULL, &selected_line ); + token_match, NULL, &selected_line , FALSE); if ( mretv == MENU_NEXT ) { retv = NEXT_DIALOG; diff --git a/source/ssh-dialog.c b/source/ssh-dialog.c index 2ac30089..4d7c10f9 100644 --- a/source/ssh-dialog.c +++ b/source/ssh-dialog.c @@ -230,7 +230,8 @@ SwitcherMode ssh_switcher_dialog ( char **input, void *data ) int shift = 0; int selected_line = 0; - int mretv = menu ( cmd_list, cmd_list_length, input, "ssh:", NULL, &shift, token_match, NULL, &selected_line ); + int mretv = menu ( cmd_list, cmd_list_length, input, "ssh:", + NULL, &shift, token_match, NULL, &selected_line, config.levenshtein_sort ); if ( mretv == MENU_NEXT ) { retv = NEXT_DIALOG;