mirror of
https://github.com/labwc/labwc.git
synced 2026-04-16 08:21:26 -04:00
menu: skip whitespace and unicode emojis before defining accelerators
Skip any character whose value in the ASCII table is larger than 127 (I think all non-ASCII chars follow this rule). Also skip any whitespace.
This commit is contained in:
parent
667707c029
commit
cea22422d5
1 changed files with 11 additions and 0 deletions
|
|
@ -145,6 +145,17 @@ item_create(struct menu *menu, const char *text, const char *icon_name, bool sho
|
|||
menuitem->arrow = show_arrow ? "›" : NULL;
|
||||
|
||||
const char *it = text;
|
||||
/* Skip emojis and whitespace */
|
||||
while (*it != '\0') {
|
||||
unsigned char c = (unsigned char)*it;
|
||||
|
||||
if (isspace(c) || c > 127) {
|
||||
it++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
menuitem->accelerator = tolower(*it);
|
||||
while (*it != '\0') {
|
||||
if (*it == '_') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue