From: NeilBrown Date: Fri, 1 Sep 2023 23:26:07 +0000 (+1000) Subject: menu: flip args to menu-add X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=102840a183ec8efb424c830cad6a95c2b0c3c1bd;p=edlib.git menu: flip args to menu-add Rather then action, then name, pass name then action to menu-add. Action default to name. This seems more natural. Signed-off-by: NeilBrown --- diff --git a/lib-menu.c b/lib-menu.c index b4bcfef1..a082c197 100644 --- a/lib-menu.c +++ b/lib-menu.c @@ -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>%name%shortcut"); else attr_set_str(&docp->attrs, "line-format", "<%BG>%name"); diff --git a/python/lib-autospell.py b/python/lib-autospell.py index f40d31a0..c19e7b8b 100644 --- a/python/lib-autospell.py +++ b/python/lib-autospell.py @@ -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 diff --git a/python/module-notmuch.py b/python/module-notmuch.py index 6832b1a8..93fe5d76 100644 --- a/python/module-notmuch.py +++ b/python/module-notmuch.py @@ -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