diff --git a/common/content/completion.js b/common/content/completion.js index 0c1c2dfe..b59304c2 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -1614,14 +1614,16 @@ function Completion() //{{{ // FIXME: Line/Column doesn't make sense with % context.title = ["Mark", "Line Column File"]; - context.keys = { - text: 0, - description: function ([,m]) percent(m.position.y) + "% " + percent(m.position.x) + "% " + m.location - }; + context.keys.description = function ([,m]) percent(m.position.y) + "% " + percent(m.position.x) + "% " + m.location; context.completions = marks.all; }, - menuItem: function menuItem(filter) commands.get("emenu").completer(filter), // XXX + menuItem: function menuItem(context) + { + context.title = ["Menu Path", "Label"]; + context.keys = { text: "fullMenuPath", description: "label" }; + context.completions = liberator.menuItems; + }, option: function option(context, scope) { diff --git a/common/content/liberator.js b/common/content/liberator.js index dd5d396c..4478c61d 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -206,6 +206,34 @@ const liberator = (function () //{{{ function () { liberator.quit(true); }); }); + // TODO: move this + function getMenuItems() + { + function addChildren(node, parent) + { + for (let [,item] in Iterator(node.childNodes)) + { + if (item.childNodes.length == 0 && item.localName == "menuitem" + && !/rdf:http:/.test(item.label)) // FIXME + { + item.fullMenuPath = parent + item.label; + items.push(item); + } + else + { + let path = parent; + if (item.localName == "menu") + path += item.label + "."; + addChildren(item, path); + } + } + } + + let items = []; + addChildren(document.getElementById(config.guioptions["m"][1]), ""); + return items; + } + registerObserver("load_commands", function () { commands.add(["addo[ns]"], @@ -256,34 +284,6 @@ const liberator = (function () //{{{ completer: function (context, args) completion.dialog(context) }); - // TODO: move this - function getMenuItems() - { - function addChildren(node, parent) - { - for (let [,item] in Iterator(node.childNodes)) - { - if (item.childNodes.length == 0 && item.localName == "menuitem" - && !/rdf:http:/.test(item.label)) // FIXME - { - item.fullMenuPath = parent + item.label; - items.push(item); - } - else - { - let path = parent; - if (item.localName == "menu") - path += item.label + "."; - addChildren(item, path); - } - } - } - - let items = []; - addChildren(document.getElementById(config.guioptions["m"][1]), ""); - return items; - } - commands.add(["em[enu]"], "Execute the specified menu item from the command line", function (args) @@ -305,13 +305,7 @@ const liberator = (function () //{{{ }, { argCount: "1", - // TODO: add this as a standard menu completion function - completer: function (context) - { - context.title = ["Menu Path", "Label"]; - context.keys = { text: "fullMenuPath", description: "label" }; - context.completions = getMenuItems(); - }, + completer: function (context) completion.menuItem(context), literal: 0 }); @@ -597,6 +591,8 @@ const liberator = (function () //{{{ get mode() modes.main, set mode(value) modes.main = value, + get menuItems() getMenuItems(), + // Global constants CURRENT_TAB: 1, NEW_TAB: 2,