Merge remote-tracking branch 'github/next' into calc-broken-fix

This commit is contained in:
Dave Davenport 2023-02-16 19:34:56 +01:00
commit 68aecdc5dd
2 changed files with 15 additions and 18 deletions

View File

@ -175,30 +175,25 @@ static gchar *prefix_regex(const char *input) {
return retv;
}
static char *utf8_helper_simplify_string(const char *s) {
gunichar buf2[G_UNICHAR_MAX_DECOMPOSITION_LENGTH] = {
0,
};
static char *utf8_helper_simplify_string(const char *os) {
char buf[6] = {
0,
};
// Compose the string in maximally composed form.
// Normalize the string to a fully decomposed form, then filter out mark/accent characters.
char *s = g_utf8_normalize(os, -1, G_NORMALIZE_ALL);
ssize_t str_size = (g_utf8_strlen(s, -1) * 6 + 2 + 1) * sizeof(char);
char *str = g_malloc0(str_size);
char *striter = str;
for (const char *iter = s; iter && *iter; iter = g_utf8_next_char(iter)) {
gunichar uc = g_utf8_get_char(iter);
int l = 0;
gsize dl = g_unichar_fully_decompose(uc, FALSE, buf2,
G_UNICHAR_MAX_DECOMPOSITION_LENGTH);
if (dl) {
l = g_unichar_to_utf8(buf2[0], buf);
} else {
l = g_unichar_to_utf8(uc, buf);
if (!g_unichar_ismark(uc)) {
int l = g_unichar_to_utf8(uc, buf);
memcpy(striter, buf, l);
striter += l;
}
memcpy(striter, buf, l);
striter += l;
}
g_free(s);
return str;
}

View File

@ -514,6 +514,7 @@ static int dmenu_mode_init(Mode *sw) {
DmenuModePrivateData *pd = (DmenuModePrivateData *)mode_get_private_data(sw);
pd->async = TRUE;
pd->multi_select = FALSE;
// For now these only work in sync mode.
if (find_arg("-sync") >= 0 || find_arg("-dump") >= 0 ||
@ -522,6 +523,10 @@ static int dmenu_mode_init(Mode *sw) {
find_arg("-selected-row") >= 0) {
pd->async = FALSE;
}
if ( find_arg("-multi-select") >= 0 ) {
pd->multi_select = TRUE;
pd->async = FALSE;
}
pd->separator = '\n';
pd->selected_line = UINT32_MAX;
@ -907,14 +912,11 @@ int dmenu_mode_dialog(void) {
DmenuScriptEntry *cmd_list = pd->cmd_list;
pd->only_selected = FALSE;
pd->multi_select = FALSE;
pd->ballot_selected = "";
pd->ballot_unselected = "";
find_arg_str("-ballot-selected-str", &(pd->ballot_selected));
find_arg_str("-ballot-unselected-str", &(pd->ballot_unselected));
if (find_arg("-multi-select") >= 0) {
pd->multi_select = TRUE;
}
if (find_arg("-markup-rows") >= 0) {
pd->do_markup = TRUE;
}