summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2010-01-15 16:40:29 -0500
committerDana Jansens <danakj@orodu.net>2010-01-15 16:40:29 -0500
commit16433ce06c083de8c725b8dc906f47c1333e3b33 (patch)
treefe5c050454252eb7e9e74028dbf0f8fd57bf0bcf /openbox
parent1e72cf5e4547968825d29e6f32491b4486cf186e (diff)
allow multiple escaped _'s in a menu label, and allow a real _ to come later in the label (Fixes bug #4355).
Diffstat (limited to 'openbox')
-rw-r--r--openbox/menu.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/openbox/menu.c b/openbox/menu.c
index 6dd6d072..634a0d9c 100644
--- a/openbox/menu.c
+++ b/openbox/menu.c
@@ -218,6 +218,7 @@ static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut,
*strippedlabel = NULL;
} else {
gchar *i;
+ gboolean escape;
*strippedlabel = g_strdup(label);
@@ -225,20 +226,33 @@ static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut,
have to just use the first valid character
*/
- i = strchr(*strippedlabel, '_');
+ /* allow __ to escape an underscore */
+ i = *strippedlabel;
+ do {
+ escape = FALSE;
+ i = strchr(i, '_');
+ if (i && *(i+1) == '_') {
+ gchar *j;
+
+ /* remove the escape '_' from the string */
+ for (j = i; *j != '\0'; ++j)
+ *j = *(j+1);
+
+ ++i;
+ escape = TRUE;
+ }
+ } while (escape);
+
if (allow_shortcut && i != NULL) {
/* there is an underscore in the string */
/* you have to use a printable ascii character for shortcuts
don't allow space either, so you can have like "a _ b"
*/
- if (VALID_SHORTCUT(*(i+1)) || *(i+1) == '_') {
- /* Allow you to escape the first _ by putting __ */
- if (*(i+1) != '_') {
- shortcut = g_unichar_tolower(g_utf8_get_char(i+1));
- *position = i - *strippedlabel;
- *always_show = TRUE;
- }
+ if (VALID_SHORTCUT(*(i+1))) {
+ shortcut = g_unichar_tolower(g_utf8_get_char(i+1));
+ *position = i - *strippedlabel;
+ *always_show = TRUE;
/* remove the '_' from the string */
for (; *i != '\0'; ++i)