Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dmenu] Pre-check boxes on multi-select #1808

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion doc/rofi-dmenu.5
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions doc/rofi-dmenu.5.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
Expand All @@ -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.

Expand Down Expand Up @@ -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`

Expand Down Expand Up @@ -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'

Expand Down
8 changes: 7 additions & 1 deletion source/modes/dmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
}
}
Expand Down