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