1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

[DMenu|Script] Add per row urgent/active option.

Instead of having a global list of entries to highlight urgent/active,
you can now to it per row.
This commit is contained in:
Dave Davenport 2023-01-08 12:10:40 +01:00
parent 236c12bfb2
commit 9fda280be1
5 changed files with 34 additions and 1 deletions

View file

@ -165,6 +165,10 @@ The following options are supported:
\fBnonselectable\fP: If true the row cannot activated.
.IP \(bu 2
\fBinfo\fP: Info that, on selection, gets placed in the \fB\fCROFI_INFO\fR environment variable. This entry does not get searched.
.IP \(bu 2
\fBurgent\fP: Set urgent flag on entry (true/false)
.IP \(bu 2
\fBactive\fP: Set active flag on entry (true/false)
.RE

View file

@ -112,6 +112,8 @@ The following options are supported:
* **meta**: Specify invisible search terms.
* **nonselectable**: If true the row cannot activated.
* **info**: Info that, on selection, gets placed in the `ROFI_INFO` environment variable. This entry does not get searched.
* **urgent**: Set urgent flag on entry (true/false)
* **active**: Set active flag on entry (true/false)
multiple entries can be passed using the `\x1f` separator.

View file

@ -21,6 +21,11 @@ typedef struct {
/** non-selectable */
gboolean nonselectable;
/** urgent */
gboolean urgent;
/** active */
gboolean active;
} DmenuScriptEntry;
/**
* @param sw Unused

View file

@ -168,6 +168,8 @@ static void read_add(DmenuModePrivateData *pd, char *data, gsize len) {
pd->cmd_list[pd->cmd_list_length].icon_name = NULL;
pd->cmd_list[pd->cmd_list_length].meta = NULL;
pd->cmd_list[pd->cmd_list_length].info = NULL;
pd->cmd_list[pd->cmd_list_length].active = FALSE;
pd->cmd_list[pd->cmd_list_length].urgent = FALSE;
pd->cmd_list[pd->cmd_list_length].nonselectable = FALSE;
char *end = data;
while (end < data + len && *end != '\0') {
@ -448,6 +450,12 @@ static char *get_display_data(const Mode *data, unsigned int index, int *state,
if (pd->do_markup) {
*state |= MARKUP;
}
if ( pd->cmd_list[index].urgent ) {
*state |= URGENT;
}
if ( pd->cmd_list[index].active ) {
*state |= ACTIVE;
}
char *my_retv =
(get_entry ? dmenu_format_output_string(pd, retv[index].entry, index,
pd->multi_select)

View file

@ -94,7 +94,13 @@ void dmenuscript_parse_entry_extras(G_GNUC_UNUSED Mode *sw,
} else if (strcasecmp(key, "info") == 0) {
entry->info = value;
} else if (strcasecmp(key, "nonselectable") == 0) {
entry->nonselectable = strcasecmp(value, "true") == 0;
entry->nonselectable = g_ascii_strcasecmp(value, "true") == 0;
g_free(value);
} else if (strcasecmp(key, "urgent") == 0) {
entry->urgent = g_ascii_strcasecmp(value, "true") == 0;
g_free(value);
} else if (strcasecmp(key, "active") == 0) {
entry->active = g_ascii_strcasecmp(value, "true") == 0;
g_free(value);
} else {
g_free(value);
@ -231,6 +237,8 @@ static DmenuScriptEntry *execute_executor(Mode *sw, char *arg,
retv[(*length)].icon_name = NULL;
retv[(*length)].meta = NULL;
retv[(*length)].info = NULL;
retv[(*length)].active = FALSE;
retv[(*length)].urgent = FALSE;
retv[(*length)].icon_fetch_uid = 0;
retv[(*length)].icon_fetch_size = 0;
retv[(*length)].nonselectable = FALSE;
@ -413,6 +421,12 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line,
*state |= URGENT;
}
}
if ( pd->cmd_list[selected_line].urgent ) {
*state |= URGENT;
}
if ( pd->cmd_list[selected_line].active ) {
*state |= ACTIVE;
}
if (pd->do_markup) {
*state |= MARKUP;
}