]> git.neil.brown.name Git - edlib.git/commitdiff
menu: flip args to menu-add
authorNeilBrown <neil@brown.name>
Fri, 1 Sep 2023 23:26:07 +0000 (09:26 +1000)
committerNeilBrown <neil@brown.name>
Mon, 4 Sep 2023 23:07:48 +0000 (09:07 +1000)
Rather then action, then name, pass name then action
to menu-add. Action default to name.
This seems more natural.

Signed-off-by: NeilBrown <neil@brown.name>
lib-menu.c
python/lib-autospell.py
python/module-notmuch.py

index b4bcfef16518a68f3e281e95e43b98f5a887ed45..a082c197d769872ba146a6acaeb32059dc056b72 100644 (file)
@@ -7,7 +7,8 @@
  * A menu is created by called attach-menu with x,y being location
  * in either the pane or (if str contains 'D') the dispay.
  * Entries are added by calling "menu-add" with str being the value to
- * be reported and optionally str2 being the name to display.
+ * be displayed (the name) and optionally str2 being a different value
+ * to be reported (the action).
  *
  * A popup will be created which takes the focus. up/down moves the selection
  * and enter selects, as can the mouse.
@@ -30,9 +31,9 @@ DEF_CMD(menu_add)
        call("doc:set-ref", ci->focus, 0, m);
        call("doc:list-add", ci->focus, 0, m);
        call("doc:set-attr", ci->focus, 0, m, "name", 0, NULL,
-            ci->str2 ?: ci->str);
-       call("doc:set-attr", ci->focus, 0, m, "value", 0, NULL,
             ci->str);
+       call("doc:set-attr", ci->focus, 0, m, "action", 0, NULL,
+            ci->str2 ?: ci->str);
        if (ci->num & 1)
                call("doc:set-attr", ci->focus, 0, m, "disabled",
                     0, NULL, "1");
@@ -54,8 +55,8 @@ DEF_CMD(menu_attr)
        }
        if (ci->str && strcmp(ci->str, "shortcut") == 0) {
                char *s = call_ret(str, "doc:get-attr", ci->home,
-                                  0, ci->mark, "value");
-               /* a leading space on 'value' suppresses listing as a shortcut */
+                                  0, ci->mark, "action");
+               /* a leading space on 'action' suppresses listing as a shortcut */
                char *v = (s && *s != ' ') ? s : "";
                comm_call(ci->comm2, "cb", ci->focus, 0, ci->mark,
                          v, 0, NULL, ci->str);
@@ -97,7 +98,7 @@ DEF_CMD(menu_done)
                m = call_ret(mark, "doc:point", ci->focus);
        if (!m)
                return Enoarg;
-       val = pane_mark_attr(ci->focus, m, "value");
+       val = pane_mark_attr(ci->focus, m, "action");
        call("popup:close", ci->focus, 0, m, val);
        return 1;
 }
@@ -124,7 +125,7 @@ DEF_CMD(menu_attach)
        attr_set_int(&docp->attrs, "render-wrap", 0);
        attr_set_str(&docp->attrs, "heading", "");
        if (ci->num & 1)
-               /* show the 'value' - presumably a key name */
+               /* show the 'action' - presumably a key name */
                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</></>");
index f40d31a029eb00e76bdf90b18db8cc3c32c6d8f9..c19e7b8b26d22a72221c32a3cbef1992b4a88c16 100644 (file)
@@ -240,8 +240,8 @@ class autospell_view(edlib.Pane):
         st = mark.dup()
         w = focus.call("Spell:ThisWord", focus, mark, st, ret='str')
         self.thisword = w
-        mp.call("menu-add", "+", "[Insert in dict]")
-        mp.call("menu-add", "!", "[Accept for now]")
+        mp.call("menu-add", "[Insert in dict]", "+")
+        mp.call("menu-add", "[Accept for now]", "!")
         focus.call("Spell:Suggest", w, lambda key, str1, **a: mp.call("menu-add", str1))
         mp.call("doc:file", -1)
         self.menu = mp
index 6832b1a8237f5373cb17d03201a11c415142694c..93fe5d76f00b49beedc00e4dca9c1b5d974533e1 100644 (file)
@@ -3572,7 +3572,7 @@ class notmuch_message_view(edlib.Pane):
             addr = ad[0][1]
         focus.call("Message", "Menu for address %s" % addr)
         mp = self.call("attach-menu", "", "notmuch-addr-choice", xy, ret='pane')
-        mp.call("menu-add", "C", "Compose")
+        mp.call("menu-add", "Compose", "C")
         q = focus.call("doc:notmuch:get-query", "from-list", ret='str')
         if q:
             for t in q.split():
@@ -3580,9 +3580,9 @@ class notmuch_message_view(edlib.Pane):
                     t = t[6:]
                     qq = focus.call("doc:notmuch:get-query", t, ret='str')
                     if qq and ("from:"+addr) in qq:
-                        mp.call("menu-add", 1, "-" + t, 'Already in "%s"' % t)
+                        mp.call("menu-add", 1, 'Already in "%s"' % t, "-" + t)
                     else:
-                        mp.call("menu-add", t, 'Add to "%s"' % t)
+                        mp.call("menu-add", 'Add to "%s"' % t, t)
         mp.call("doc:file", -1)
         self.menu = mp
         self.addr = addr