mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 10:57:58 +01:00
More dactyl.generateHelp improvements.
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
* @property {string} description A description of the option
|
||||
*/
|
||||
|
||||
const CommandOption = Struct("names", "type", "validator", "completer", "multiple", "description");
|
||||
const CommandOption = Struct("names", "type", "validator", "completer", "multiple", "description", "default");
|
||||
CommandOption.defaultValue("description", function () "");
|
||||
CommandOption.defaultValue("type", function () CommandOption.NOARG);
|
||||
CommandOption.defaultValue("multiple", function () false);
|
||||
|
||||
@@ -642,16 +642,7 @@ const Dactyl = Module("dactyl", {
|
||||
let br = <>
|
||||
</>;
|
||||
|
||||
if (obj.completer)
|
||||
var completions = let (br = br + <> </>) <>
|
||||
<dl>{ br +
|
||||
template.map(
|
||||
completion._runCompleter(obj.completer, "", null, args).items,
|
||||
function (i) <><dt>{i.text}</dt> <dd>{i.description}</dd></>,
|
||||
br) }
|
||||
</dl></>;
|
||||
|
||||
return <>
|
||||
let res = <res>
|
||||
<dt>{link(obj.name)}</dt> <dd>{obj.description ? obj.description.replace(/\.$/, "") : ""}</dd>
|
||||
<item>
|
||||
<tags>{template.map(obj.names, tag, " ")}</tags>
|
||||
@@ -662,10 +653,34 @@ const Dactyl = Module("dactyl", {
|
||||
<description>{
|
||||
obj.description ? br+<p>{obj.description.replace(/\.?$/, ".")}</p> : "" }{
|
||||
extraHelp ? br+extraHelp : "" }{
|
||||
!(extraHelp || obj.description) ? br+<p>Sorry, no help available.</p> : "" }{
|
||||
completions ? br + completions : "" }
|
||||
!(extraHelp || obj.description) ? br+<p>Sorry, no help available.</p> : "" }
|
||||
</description>
|
||||
</item></>.toXMLString().replace(/^ {12}/gm, "");
|
||||
</item></res>;
|
||||
|
||||
function add(ary) {
|
||||
res.item.description.* += br +
|
||||
let (br = br + <> </>)
|
||||
<><dl>{ br + template.map(ary, function ([a, b]) <><dt>{a}</dt> <dd>{b}</dd></>, br) }
|
||||
</dl>
|
||||
</>;
|
||||
}
|
||||
|
||||
if (obj.completer)
|
||||
add(completion._runCompleter(obj.completer, "", null, args).items
|
||||
.map(function (i) [i.text, i.description]));
|
||||
|
||||
if (obj.options && obj.options.some(function (o) o.description))
|
||||
add(obj.options.filter(function (o) o.description)
|
||||
.map(function (o) [
|
||||
o.names[0],
|
||||
<>{o.description}{
|
||||
o.names.length == 1 ? "" :
|
||||
<> (short name: {
|
||||
template.map(o.names.slice(1), function (n) <em>{n}</em>, <>, </>)
|
||||
})</>
|
||||
}</>
|
||||
]));
|
||||
return res.*.toXMLString().replace(/^ {12}/gm, "");;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -195,11 +195,11 @@ const History = Module("history", {
|
||||
|
||||
commands.add(["hist[ory]", "hs"],
|
||||
"Show recently visited URLs",
|
||||
function (args) { history.list(args.join(" "), args.bang, args["-max"] || 1000); }, {
|
||||
function (args) { history.list(args.join(" "), args.bang, args["-max"]); }, {
|
||||
bang: true,
|
||||
completer: function (context) { context.quote = null; completion.history(context); },
|
||||
// completer: function (filter) completion.history(filter)
|
||||
options: [{ names: ["-max", "-m"], description: "The maximum number of items to list", type: CommandOption.INT }],
|
||||
options: [{ names: ["-max", "-m"], description: "The maximum number of items to list", default: 1000, type: CommandOption.INT }],
|
||||
privateData: true
|
||||
});
|
||||
},
|
||||
|
||||
@@ -351,7 +351,7 @@ const Mappings = Module("mappings", {
|
||||
// 1 arg -> list the maps starting with args
|
||||
// 2 args -> map arg1 to arg*
|
||||
function map(args, mapmodes, noremap) {
|
||||
mapmodes = getModes(args, mapmodes);
|
||||
mapmodes = getModes(args);
|
||||
if (!args.length) {
|
||||
mappings.list(mapmodes);
|
||||
return;
|
||||
@@ -394,8 +394,8 @@ const Mappings = Module("mappings", {
|
||||
return mode.mask;
|
||||
return null;
|
||||
}
|
||||
function getModes(args, def)
|
||||
array.uniq((args["-modes"] || def || ["n", "v"]).map(findMode));
|
||||
function getModes(args)
|
||||
array.uniq(args["-modes"].map(findMode));
|
||||
function uniqueModes(modes) {
|
||||
modes = modes.map(modules.modes.closure.getMode);
|
||||
let chars = [k for ([k, v] in Iterator(modules.modes.modeChars))
|
||||
@@ -442,6 +442,7 @@ const Mappings = Module("mappings", {
|
||||
names: ["-modes", "-mode", "-m"],
|
||||
type: CommandOption.LIST,
|
||||
description: "Create this mapping in the given modes",
|
||||
default: mapmodes || ["n", "v"],
|
||||
validator: function (list) !list || list.every(findMode),
|
||||
completer: function () [[array.compact([mode.name.toLowerCase(), mode.char]), mode.disp]
|
||||
for (mode in modes.mainModes)],
|
||||
|
||||
@@ -213,6 +213,8 @@ function debuggerProperties(obj) {
|
||||
* @returns {Generator}
|
||||
*/
|
||||
function prototype(obj)
|
||||
// Temporary hack:
|
||||
typeof obj === "xml" || obj.__proto__ !== obj.__proto__ ? null :
|
||||
obj.__proto__ || Object.getPrototypeOf(obj) ||
|
||||
XPCNativeWrapper.unwrap(obj).__proto__ ||
|
||||
Object.getPrototypeOf(XPCNativeWrapper.unwrap(obj));
|
||||
|
||||
Reference in New Issue
Block a user