]> git.neil.brown.name Git - edlib.git/commitdiff
lib-menu: be more consistent in setting 'mode' of menu
authorNeilBrown <neil@brown.name>
Sun, 3 Sep 2023 11:52:35 +0000 (21:52 +1000)
committerNeilBrown <neil@brown.name>
Mon, 4 Sep 2023 23:07:53 +0000 (09:07 +1000)
Rather than using the string of one mode flag and the num for
another, use the string for all.

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

index 5b0f17ba3b85df06475a7ecf293d5a94e7b3e511..ab21cb46b69ca2c480ab6daacc6ced0a0eb3c747 100644 (file)
@@ -118,6 +118,10 @@ DEF_LOOKUP_CMD(menu_handle, menu_map);
 
 DEF_CMD(menu_attach)
 {
+       /* ->str gives the "mode"
+        * D  means per-display menu, not per-pane
+        * V  means show value in menu as well as name
+        */
        struct pane *docp, *p, *p2;
        /* Multi-line temporary popup with x,y location provided. */
        const char *mode = "Mtx";
@@ -133,11 +137,13 @@ DEF_CMD(menu_attach)
        call("doc:set:autoclose", docp, 1);
        attr_set_str(&docp->attrs, "render-simple", "format");
        attr_set_str(&docp->attrs, "heading", "");
-       if (ci->num & 1)
+       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</></>");
+               attr_set_str(&docp->attrs, "line-format",
+                            "<%BG><action-activate:menu-select>%name<rtab>%shortcut</></>");
        else
-               attr_set_str(&docp->attrs, "line-format", "<%BG><action-activate:menu-select>%name</></>");
+               attr_set_str(&docp->attrs, "line-format",
+                            "<%BG><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", "");