From 602eb6355701d58c273006d3c4541adf21a7dd13 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Mon, 18 Jul 2016 23:58:08 +0200 Subject: [PATCH] Add ``-multi-select` flag to dmenu. * Changes default behaviour. --- doc/rofi-manpage.markdown | 4 ++-- doc/rofi.1 | 4 ++-- source/dialogs/dmenu.c | 12 +++++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index 22d5a18a..501872f6 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -582,9 +582,9 @@ Tell **rofi** that DMenu input is pango markup encoded and should be rendered. See [here](https://developer.gnome.org/pango/stable/PangoMarkupFormat.html) for details about pango markup. -`-no-selection-indicator` +`-multi-select` -Hides the selection indicator. This will make multi-select be invisible. +Allow multiple lines to be selected. Adds a small selection indicator to the left of each entry. ### Window Mode diff --git a/doc/rofi.1 b/doc/rofi.1 index 5661c124..9cb424c1 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -930,10 +930,10 @@ Hide the input text\. This should not be considered secure! Tell \fBrofi\fR that DMenu input is pango markup encoded and should be rendered\. See here \fIhttps://developer\.gnome\.org/pango/stable/PangoMarkupFormat\.html\fR for details about pango markup\. . .P -\fB\-no\-selection\-indicator\fR +\fB\-multi\-select\fR . .P -Hides the selection indicator\. This will make multi\-select be invisible\. +Allow multiple lines to be selected\. Adds a small selection indicator to the left of each entry\. . .SS "Window Mode" \fB\-window\-format\fR \fIformat\fR diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index 0303d1b2..4114452a 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -90,6 +90,7 @@ typedef struct gchar **columns; gchar *column_separator; + gboolean multi_select; } DmenuModePrivateData; static char **get_dmenu ( DmenuModePrivateData *pd, FILE *fd, unsigned int *length ) @@ -469,7 +470,7 @@ static void dmenu_finalize ( RofiViewState *state ) restart = FALSE; // Normal mode if ( ( mretv & MENU_OK ) && pd->selected_line != UINT32_MAX && cmd_list[pd->selected_line] != NULL ) { - if ( ( mretv & MENU_CUSTOM_ACTION ) ) { + if ( ( mretv & MENU_CUSTOM_ACTION ) && pd->multi_select ) { restart = TRUE; if ( pd->selected_list == NULL ) { pd->selected_list = g_malloc0 ( sizeof ( uint32_t ) * ( pd->cmd_list_length / 32 + 1 ) ); @@ -541,16 +542,17 @@ static void dmenu_finalize ( RofiViewState *state ) int dmenu_switcher_dialog ( void ) { mode_init ( &dmenu_mode ); - MenuFlags menu_flags = MENU_INDICATOR; + MenuFlags menu_flags = MENU_NORMAL; DmenuModePrivateData *pd = (DmenuModePrivateData *) dmenu_mode.private_data; char *input = NULL; unsigned int cmd_list_length = pd->cmd_list_length; char **cmd_list = pd->cmd_list; pd->only_selected = FALSE; - - if ( find_arg ( "-no-selection-indicator") >= 0 ){ - menu_flags = MENU_NORMAL; + pd->multi_select = FALSE; + if ( find_arg ( "-multi-select" ) >= 0 ) { + menu_flags = MENU_INDICATOR; + pd->multi_select = TRUE; } if ( find_arg ( "-markup-rows" ) >= 0 ) { pd->do_markup = TRUE;