From 06f9fee3f8ba0e1a7d8b421fb8aecb4e3291db5e Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Mon, 14 Dec 2015 21:02:36 +0100 Subject: [PATCH] Add indicator for sorting/case sensitive. --- doc/rofi-manpage.markdown | 8 +++++++- doc/rofi.1 | 17 ++++++++++++++++- source/rofi.c | 33 +++++++++++++++++++++------------ 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index d9b744c1..7f7a8b19 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -822,10 +822,16 @@ Allows custom scripted Modi to be added. Try using a mono-space font. -`**rofi** is completely black.` +**rofi** is completely black. Check quotes used on the commandline: e.g. used “ instead of ". +**rofi** what does the icon in the top right show? + + - Case sensitivity enabled + + Sorting enabled + ± Sorting and Case sensitivity enabled" + ## LICENSE MIT/X11 diff --git a/doc/rofi.1 b/doc/rofi.1 index b879eb8f..ebd5fe66 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -1350,7 +1350,7 @@ Try using a mono\-space font\. .IP "" 0 . .P -\fB**rofi** is completely black\.\fR +\fBrofi\fR is completely black\. . .IP "" 4 . @@ -1362,6 +1362,21 @@ Check quotes used on the commandline: e\.g\. used “ instead of "\. . .IP "" 0 . +.P +\fBrofi\fR what does the icon in the top right show? +. +.IP "" 4 +. +.nf + +\- Case sensitivity enabled ++ Sorting enabled +± Sorting and Case sensitivity enabled" +. +.fi +. +.IP "" 0 +. .SH "LICENSE" . .nf diff --git a/source/rofi.c b/source/rofi.c index edf16631..84116b74 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -98,6 +98,24 @@ XIC xic; GThreadPool *tpool = NULL; +static char * get_matching_state ( void ) +{ + if ( config.case_sensitive ) { + if ( config.levenshtein_sort ) { + return "±"; + } + else { + return "-"; + } + } + else{ + if ( config.levenshtein_sort ) { + return "+"; + } + } + return " "; +} + /** * @param name Name of the switcher to lookup. * @@ -1351,12 +1369,7 @@ MenuReturn menu ( Mode *sw, char **input, char *prompt, unsigned int *selected_l // Move indicator to end. textbox_move ( state.case_indicator, state.border + textbox_get_width ( state.prompt_tb ) + entrybox_width, state.border ); - if ( config.case_sensitive ) { - textbox_text ( state.case_indicator, "*" ); - } - else{ - textbox_text ( state.case_indicator, " " ); - } + textbox_text ( state.case_indicator, get_matching_state () ); state.message_tb = NULL; if ( message ) { state.message_tb = textbox_create ( TB_AUTOHEIGHT | TB_MARKUP | TB_WRAP, @@ -1567,6 +1580,7 @@ MenuReturn menu ( Mode *sw, char **input, char *prompt, unsigned int *selected_l config.levenshtein_sort = !config.levenshtein_sort; state.refilter = TRUE; state.update = TRUE; + textbox_text ( state.case_indicator, get_matching_state () ); break; } else if ( abe_test_action ( MODE_PREVIOUS, ev.xkey.state, key ) ) { @@ -1588,12 +1602,7 @@ MenuReturn menu ( Mode *sw, char **input, char *prompt, unsigned int *selected_l *( state.selected_line ) = 0; state.refilter = TRUE; state.update = TRUE; - if ( config.case_sensitive ) { - textbox_text ( state.case_indicator, "*" ); - } - else { - textbox_text ( state.case_indicator, " " ); - } + textbox_text ( state.case_indicator, get_matching_state () ); break; } // Special delete entry command.