mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 11:07:58 +01:00
Use options.list() for displaying option values.
--HG-- branch : bootstrapped
This commit is contained in:
@@ -720,26 +720,25 @@ var Options = Module("options", {
|
|||||||
* Lists all options in *scope* or only those with changed values if
|
* Lists all options in *scope* or only those with changed values if
|
||||||
* *onlyNonDefault* is specified.
|
* *onlyNonDefault* is specified.
|
||||||
*
|
*
|
||||||
* @param {boolean} onlyNonDefault Limit the list to prefs with a
|
* @param {function(Option)} filter Limit the list
|
||||||
* non-default value.
|
|
||||||
* @param {number} scope Only list options in this scope (see
|
* @param {number} scope Only list options in this scope (see
|
||||||
* {@link Option#scope}).
|
* {@link Option#scope}).
|
||||||
*/
|
*/
|
||||||
list: function (onlyNonDefault, scope) {
|
list: function (filter, scope) {
|
||||||
if (!scope)
|
if (!scope)
|
||||||
scope = Option.SCOPE_BOTH;
|
scope = Option.SCOPE_BOTH;
|
||||||
|
|
||||||
function opts(opt) {
|
function opts(opt) {
|
||||||
for (let opt in Iterator(options)) {
|
for (let opt in Iterator(options)) {
|
||||||
let option = {
|
let option = {
|
||||||
|
__proto__: opt,
|
||||||
isDefault: opt.isDefault,
|
isDefault: opt.isDefault,
|
||||||
name: opt.name,
|
|
||||||
default: opt.stringDefaultValue,
|
default: opt.stringDefaultValue,
|
||||||
pre: "\u00a0\u00a0", // Unicode nonbreaking space.
|
pre: "\u00a0\u00a0", // Unicode nonbreaking space.
|
||||||
value: <></>
|
value: <></>,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (onlyNonDefault && option.isDefault)
|
if (filter && !filter(opt))
|
||||||
continue;
|
continue;
|
||||||
if (!(opt.scope & scope))
|
if (!(opt.scope & scope))
|
||||||
continue;
|
continue;
|
||||||
@@ -757,7 +756,7 @@ var Options = Module("options", {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
commandline.commandOutput(template.options("Options", opts()));
|
commandline.commandOutput(template.options("Options", opts(), options["verbose"] > 0));
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -870,6 +869,17 @@ var Options = Module("options", {
|
|||||||
if (!args.length)
|
if (!args.length)
|
||||||
args[0] = "";
|
args[0] = "";
|
||||||
|
|
||||||
|
let list = [];
|
||||||
|
function flushList() {
|
||||||
|
let names = set(list.map(function (opt) opt.option ? opt.option.name : ""));
|
||||||
|
if (list.length)
|
||||||
|
if (list.some(function (opt) opt.all))
|
||||||
|
options.list(function (opt) !(list[0].onlyNonDefault && opt.isDefault) , list[0].scope);
|
||||||
|
else
|
||||||
|
options.list(function (opt) set.has(names, opt.name), list[0].scope);
|
||||||
|
list = [];
|
||||||
|
}
|
||||||
|
|
||||||
for (let [, arg] in args) {
|
for (let [, arg] in args) {
|
||||||
if (bang) {
|
if (bang) {
|
||||||
let onlyNonDefault = false;
|
let onlyNonDefault = false;
|
||||||
@@ -931,6 +941,7 @@ var Options = Module("options", {
|
|||||||
|
|
||||||
// reset a variable to its default value
|
// reset a variable to its default value
|
||||||
if (opt.reset) {
|
if (opt.reset) {
|
||||||
|
flushList();
|
||||||
if (opt.all) {
|
if (opt.all) {
|
||||||
for (let option in options)
|
for (let option in options)
|
||||||
option.reset();
|
option.reset();
|
||||||
@@ -940,25 +951,11 @@ var Options = Module("options", {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// read access
|
// read access
|
||||||
else if (opt.get) {
|
else if (opt.get)
|
||||||
if (opt.all)
|
list.push(opt);
|
||||||
options.list(opt.onlyNonDefault, opt.scope);
|
|
||||||
else {
|
|
||||||
XML.prettyPrinting = false;
|
|
||||||
XML.ignoreWhitespace = false;
|
|
||||||
if (option.type == "boolean")
|
|
||||||
var msg = (opt.optionValue ? " " : "no") + option.name;
|
|
||||||
else
|
|
||||||
msg = " " + option.name + "=" + opt.option.stringify(opt.optionValue);
|
|
||||||
|
|
||||||
if (options["verbose"] > 0 && option.setFrom)
|
|
||||||
msg = <>{msg}<br/> Last set from {template.sourceLink(option.setFrom)}</>;
|
|
||||||
|
|
||||||
dactyl.echo(<span highlight="CmdOutput Message">{msg}</span>);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// write access
|
// write access
|
||||||
else {
|
else {
|
||||||
|
flushList();
|
||||||
if (opt.option.type === "boolean") {
|
if (opt.option.type === "boolean") {
|
||||||
dactyl.assert(!opt.valueGiven, "E474: Invalid argument: " + arg);
|
dactyl.assert(!opt.valueGiven, "E474: Invalid argument: " + arg);
|
||||||
opt.values = !opt.unsetBoolean;
|
opt.values = !opt.unsetBoolean;
|
||||||
@@ -977,6 +974,7 @@ var Options = Module("options", {
|
|||||||
option.setFrom = commands.getCaller(null);
|
option.setFrom = commands.getCaller(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
flushList();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCompleter(context, args, modifiers) {
|
function setCompleter(context, args, modifiers) {
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ var Template = Module("Template", {
|
|||||||
})(), template[help ? "HelpLink" : "helpLink"]);
|
})(), template[help ? "HelpLink" : "helpLink"]);
|
||||||
},
|
},
|
||||||
|
|
||||||
options: function options(title, opts) {
|
options: function options(title, opts, verbose) {
|
||||||
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
|
XML.ignoreWhitespace = false; XML.prettyPrinting = false;
|
||||||
// <e4x>
|
// <e4x>
|
||||||
return <table>
|
return <table>
|
||||||
@@ -249,7 +249,9 @@ var Template = Module("Template", {
|
|||||||
<div highlight="Message"
|
<div highlight="Message"
|
||||||
><span style={opt.isDefault ? "" : "font-weight: bold"}>{opt.pre}{opt.name}</span><span>{opt.value}</span>{
|
><span style={opt.isDefault ? "" : "font-weight: bold"}>{opt.pre}{opt.name}</span><span>{opt.value}</span>{
|
||||||
opt.isDefault || opt.default == null ? "" : <span class="extra-info"> (default: {opt.default})</span>
|
opt.isDefault || opt.default == null ? "" : <span class="extra-info"> (default: {opt.default})</span>
|
||||||
}</div>
|
}</div>{
|
||||||
|
verbose && opt.setFrom ? <div highlight="Message"> Last set from {template.sourceLink(opt.setFrom)}</div> : <></>
|
||||||
|
}
|
||||||
</td>
|
</td>
|
||||||
</tr>)
|
</tr>)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user