From effdecb9835261bfd8010b5a6516a46c3455cf69 Mon Sep 17 00:00:00 2001 From: khai96_ Date: Sun, 12 Feb 2023 00:52:18 +0700 Subject: [PATCH] [Dmenu] Remove the toggling behavior --- doc/rofi-dmenu.5 | 1 - doc/rofi-dmenu.5.markdown | 9 ++++----- source/modes/dmenu.c | 8 +++++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/doc/rofi-dmenu.5 b/doc/rofi-dmenu.5 index a462389b8..81fefc410 100644 --- a/doc/rofi-dmenu.5 +++ b/doc/rofi-dmenu.5 @@ -152,7 +152,6 @@ Urgent row, mark \fIX\fP as urgent. See \fB\fC-a\fR option for details. .PP If multi-select is enabled, pre-select rows, See \fB\fC-a\fR option for format details. -If same row is specified multiple times, it state is toggled on subsequential sets. .PP \fB\fC-only-match\fR diff --git a/doc/rofi-dmenu.5.markdown b/doc/rofi-dmenu.5.markdown index 2c79b675d..65996006b 100644 --- a/doc/rofi-dmenu.5.markdown +++ b/doc/rofi-dmenu.5.markdown @@ -7,7 +7,7 @@ ## DESCRIPTION -To integrate **rofi** into scripts as simple selection dialogs, +To integrate **rofi** into scripts as simple selection dialogs, **rofi** supports emulating **dmenu(1)** (A dynamic menu for X11). The website for `dmenu` can be found [here](http://tools.suckless.org/dmenu/). @@ -22,10 +22,10 @@ Besides, **rofi** offers some extended features (like multi-select, highlighting In `dmenu` mode, **rofi** reads data from standard in, splits them into separate entries and displays them. If the user selects an row, this is printed out to standard out, allow the script to process it further. -By default separation of rows is done on new lines, making it easy to pipe the output a one application into +By default separation of rows is done on new lines, making it easy to pipe the output a one application into **rofi** and the output of rofi into the next. -## USAGE +## USAGE By launching **rofi** with the `-dmenu` flag it will go into dmenu emulation mode. @@ -96,7 +96,6 @@ Urgent row, mark *X* as urgent. See `-a` option for details. `-select-rows` *X* If multi-select is enabled, pre-select rows, See `-a` option for format details. -If same row is specified multiple times, it state is toggled on subsequential sets. `-only-match` @@ -181,7 +180,7 @@ A comma seperated list of columns to show. `-display-column-separator` -The column separator. This is a regex. +The column separator. This is a regex. *default*: '\t' diff --git a/source/modes/dmenu.c b/source/modes/dmenu.c index 91bdfdc94..f3d24affd 100644 --- a/source/modes/dmenu.c +++ b/source/modes/dmenu.c @@ -74,6 +74,12 @@ static inline void bittoggle(uint32_t *const array, unsigned int index) { *v ^= 1 << bit; } +static inline void bitenable(uint32_t *const array, unsigned int index) { + uint32_t bit = index % 32; + uint32_t *v = &array[index / 32]; + *v |= 1 << bit; +} + typedef struct { /** Settings */ // Separator. @@ -176,7 +182,7 @@ static void dmenu_parse_multi_select_range ( DmenuModePrivateData *pd, const cha index = pd->cmd_list_length - index; } if ( index < (int)pd->cmd_list_length ) { - bittoggle(pd->selected_list, index); + bitenable(pd->selected_list, index); } } }