mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 11:27:58 +01:00
Fix menuItem completer, use it for :emenu
This commit is contained in:
@@ -1614,14 +1614,16 @@ function Completion() //{{{
|
|||||||
|
|
||||||
// FIXME: Line/Column doesn't make sense with %
|
// FIXME: Line/Column doesn't make sense with %
|
||||||
context.title = ["Mark", "Line Column File"];
|
context.title = ["Mark", "Line Column File"];
|
||||||
context.keys = {
|
context.keys.description = function ([,m]) percent(m.position.y) + "% " + percent(m.position.x) + "% " + m.location;
|
||||||
text: 0,
|
|
||||||
description: function ([,m]) percent(m.position.y) + "% " + percent(m.position.x) + "% " + m.location
|
|
||||||
};
|
|
||||||
context.completions = marks.all;
|
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)
|
option: function option(context, scope)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -206,6 +206,34 @@ const liberator = (function () //{{{
|
|||||||
function () { liberator.quit(true); });
|
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 ()
|
registerObserver("load_commands", function ()
|
||||||
{
|
{
|
||||||
commands.add(["addo[ns]"],
|
commands.add(["addo[ns]"],
|
||||||
@@ -256,34 +284,6 @@ const liberator = (function () //{{{
|
|||||||
completer: function (context, args) completion.dialog(context)
|
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]"],
|
commands.add(["em[enu]"],
|
||||||
"Execute the specified menu item from the command line",
|
"Execute the specified menu item from the command line",
|
||||||
function (args)
|
function (args)
|
||||||
@@ -305,13 +305,7 @@ const liberator = (function () //{{{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "1",
|
argCount: "1",
|
||||||
// TODO: add this as a standard menu completion function
|
completer: function (context) completion.menuItem(context),
|
||||||
completer: function (context)
|
|
||||||
{
|
|
||||||
context.title = ["Menu Path", "Label"];
|
|
||||||
context.keys = { text: "fullMenuPath", description: "label" };
|
|
||||||
context.completions = getMenuItems();
|
|
||||||
},
|
|
||||||
literal: 0
|
literal: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -597,6 +591,8 @@ const liberator = (function () //{{{
|
|||||||
get mode() modes.main,
|
get mode() modes.main,
|
||||||
set mode(value) modes.main = value,
|
set mode(value) modes.main = value,
|
||||||
|
|
||||||
|
get menuItems() getMenuItems(),
|
||||||
|
|
||||||
// Global constants
|
// Global constants
|
||||||
CURRENT_TAB: 1,
|
CURRENT_TAB: 1,
|
||||||
NEW_TAB: 2,
|
NEW_TAB: 2,
|
||||||
|
|||||||
Reference in New Issue
Block a user