mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
[DMenu] Fix completion with multi-select
This commit is contained in:
parent
f3064e0fee
commit
952aaae295
1 changed files with 19 additions and 8 deletions
|
@ -342,9 +342,10 @@ static unsigned int dmenu_mode_get_num_entries(const Mode *sw) {
|
||||||
|
|
||||||
static gchar *dmenu_format_output_string(const DmenuModePrivateData *pd,
|
static gchar *dmenu_format_output_string(const DmenuModePrivateData *pd,
|
||||||
const char *input,
|
const char *input,
|
||||||
const unsigned int index) {
|
const unsigned int index,
|
||||||
|
gboolean multi_select) {
|
||||||
if (pd->columns == NULL) {
|
if (pd->columns == NULL) {
|
||||||
if (pd->multi_select) {
|
if (multi_select) {
|
||||||
if (pd->selected_list && bitget(pd->selected_list, index) == TRUE) {
|
if (pd->selected_list && bitget(pd->selected_list, index) == TRUE) {
|
||||||
return g_strdup_printf("%s%s", pd->ballot_selected, input);
|
return g_strdup_printf("%s%s", pd->ballot_selected, input);
|
||||||
} else {
|
} else {
|
||||||
|
@ -362,10 +363,12 @@ static gchar *dmenu_format_output_string(const DmenuModePrivateData *pd,
|
||||||
}
|
}
|
||||||
GString *str_retv = g_string_new("");
|
GString *str_retv = g_string_new("");
|
||||||
|
|
||||||
if (pd->selected_list && bitget(pd->selected_list, index) == TRUE) {
|
if (multi_select) {
|
||||||
g_string_append(str_retv, pd->ballot_selected);
|
if (pd->selected_list && bitget(pd->selected_list, index) == TRUE) {
|
||||||
} else {
|
g_string_append(str_retv, pd->ballot_selected);
|
||||||
g_string_append(str_retv, pd->ballot_unselected);
|
} else {
|
||||||
|
g_string_append(str_retv, pd->ballot_unselected);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (uint32_t i = 0; pd->columns && pd->columns[i]; i++) {
|
for (uint32_t i = 0; pd->columns && pd->columns[i]; i++) {
|
||||||
unsigned int index =
|
unsigned int index =
|
||||||
|
@ -396,6 +399,13 @@ static inline unsigned int get_index(unsigned int length, int index) {
|
||||||
return UINT_MAX;
|
return UINT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *dmenu_get_completion_data(const Mode *data, unsigned int index) {
|
||||||
|
Mode *sw = (Mode *)data;
|
||||||
|
DmenuModePrivateData *pd = (DmenuModePrivateData *)mode_get_private_data(sw);
|
||||||
|
DmenuScriptEntry *retv = (DmenuScriptEntry *)pd->cmd_list;
|
||||||
|
return dmenu_format_output_string(pd, retv[index].entry, index, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
static char *get_display_data(const Mode *data, unsigned int index, int *state,
|
static char *get_display_data(const Mode *data, unsigned int index, int *state,
|
||||||
G_GNUC_UNUSED GList **list, int get_entry) {
|
G_GNUC_UNUSED GList **list, int get_entry) {
|
||||||
Mode *sw = (Mode *)data;
|
Mode *sw = (Mode *)data;
|
||||||
|
@ -424,7 +434,8 @@ static char *get_display_data(const Mode *data, unsigned int index, int *state,
|
||||||
*state |= MARKUP;
|
*state |= MARKUP;
|
||||||
}
|
}
|
||||||
char *my_retv =
|
char *my_retv =
|
||||||
(get_entry ? dmenu_format_output_string(pd, retv[index].entry, index)
|
(get_entry ? dmenu_format_output_string(pd, retv[index].entry, index,
|
||||||
|
pd->multi_select)
|
||||||
: NULL);
|
: NULL);
|
||||||
return my_retv;
|
return my_retv;
|
||||||
}
|
}
|
||||||
|
@ -465,7 +476,7 @@ Mode dmenu_mode = {.name = "dmenu",
|
||||||
._token_match = dmenu_token_match,
|
._token_match = dmenu_token_match,
|
||||||
._get_display_value = get_display_data,
|
._get_display_value = get_display_data,
|
||||||
._get_icon = dmenu_get_icon,
|
._get_icon = dmenu_get_icon,
|
||||||
._get_completion = NULL,
|
._get_completion = dmenu_get_completion_data,
|
||||||
._preprocess_input = NULL,
|
._preprocess_input = NULL,
|
||||||
._get_message = dmenu_get_message,
|
._get_message = dmenu_get_message,
|
||||||
.private_data = NULL,
|
.private_data = NULL,
|
||||||
|
|
Loading…
Reference in a new issue