]> git.neil.brown.name Git - edlib.git/commitdiff
menu: show action in a different colour
authorNeilBrown <neil@brown.name>
Sun, 3 Sep 2023 12:07:34 +0000 (22:07 +1000)
committerNeilBrown <neil@brown.name>
Mon, 4 Sep 2023 23:07:53 +0000 (09:07 +1000)
To make sure the name and the action look different, use a different
color (blue) for the action.

Signed-off-by: NeilBrown <neil@brown.name>
lib-menu.c

index f9202bc538ad2533648833a6afcb60ada425217a..03efa03b3f9d97f0d12c8d7ff9fe0c1af8b65fff 100644 (file)
@@ -54,7 +54,7 @@ DEF_CMD(menu_clear)
 
 DEF_CMD(menu_attr)
 {
-       if (ci->str && strcmp(ci->str, "BG") == 0) {
+       if (ci->str && strcmp(ci->str, "FG") == 0) {
                char *s = call_ret(str, "doc:get-attr", ci->home,
                                   0, ci->mark, "disabled");
                char *v = (s && *s) ? "fg:white-40" : "fg:black";
@@ -63,6 +63,15 @@ DEF_CMD(menu_attr)
                free(s);
                return 1;
        }
+       if (ci->str && strcmp(ci->str, "fg") == 0) {
+               char *s = call_ret(str, "doc:get-attr", ci->home,
+                                  0, ci->mark, "disabled");
+               char *v = (s && *s) ? "fg:blue+60" : "fg:blue";
+               comm_call(ci->comm2, "cb", ci->focus, 0, ci->mark,
+                         v, 0, NULL, ci->str);
+               free(s);
+               return 1;
+       }
        if (ci->str && strcmp(ci->str, "shortcut") == 0) {
                char *s = call_ret(str, "doc:get-attr", ci->home,
                                   0, ci->mark, "action");
@@ -147,10 +156,10 @@ DEF_CMD(menu_attach)
                if (strchr(mmode, 'V'))
                        /* show the 'action' - presumably a key name */
                        attr_set_str(&docp->attrs, "line-format",
-                                    "<%BG><action-activate:menu-select>%name<rtab>%shortcut</></>");
+                                    "<%FG><action-activate:menu-select>%name <rtab><%fg>%shortcut</></></>");
                else
                        attr_set_str(&docp->attrs, "line-format",
-                                    "<%BG><action-activate:menu-select>%name</></>");
+                                    "<%FG><action-activate:menu-select>%name</></>");
                attr_set_str(&docp->attrs, "done-key", ci->str2 ?: "menu-done");
                /* No borders, just a shaded background to make menu stand out */
                attr_set_str(&docp->attrs, "borders", "");