Add `-multi-select flag to dmenu.

* Changes default behaviour.
This commit is contained in:
Dave Davenport 2016-07-18 23:58:08 +02:00
parent 965d2c2ac5
commit 602eb63557
3 changed files with 11 additions and 9 deletions

View file

@ -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

View file

@ -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

View file

@ -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;