//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
-/* use strict */
+"use strict";
try {
-Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("options", {
exports: ["Option", "Options", "ValueError", "options"],
require: ["contexts", "messages", "storage"]
-}, this);
+});
-this.lazyRequire("config", ["config"]);
+lazyRequire("cache", ["cache"]);
+lazyRequire("config", ["config"]);
+lazyRequire("commands", ["Commands"]);
+lazyRequire("completion", ["CompletionContext"]);
+lazyRequire("prefs", ["prefs"]);
+lazyRequire("styles", ["Styles"]);
+lazyRequire("template", ["template"]);
/** @scope modules */
function opts(opt) {
for (let opt in Iterator(this)) {
+ if (filter && !filter(opt))
+ continue;
+ if (!(opt.scope & scope))
+ continue;
+
let option = {
__proto__: opt,
isDefault: opt.isDefault,
default: opt.stringDefaultValue,
pre: "\u00a0\u00a0", // Unicode nonbreaking space.
- value: <></>
+ value: []
};
- if (filter && !filter(opt))
- continue;
- if (!(opt.scope & scope))
- continue;
-
if (opt.type == "boolean") {
if (!opt.value)
option.pre = "no";
option.default = (opt.defaultValue ? "" : "no") + opt.name;
}
else if (isArray(opt.value) && opt.type != "charlist")
- option.value = <>={template.map(opt.value,
- function (v) template.highlight(String(v)),
- <>,<span style="width: 0; display: inline-block"> </span></>)}</>;
+ option.value = ["", "=",
+ template.map(opt.value,
+ function (v) template.highlight(String(v)),
+ ["", ",",
+ ["span", { style: "width: 0; display: inline-block" }, " "]])];
else
- option.value = <>={template.highlight(opt.stringValue)}</>;
+ option.value = ["", "=", template.highlight(opt.stringValue)];
yield option;
}
};
- modules.commandline.commandOutput(template.options("Options", opts.call(this), this["verbose"] > 0));
+ modules.commandline.commandOutput(
+ template.options("Options", opts.call(this), this["verbose"] > 0));
},
cleanup: function cleanup() {
commands: function initCommands(dactyl, modules, window) {
const { commands, contexts, options } = modules;
- let args = {
- getMode: function (args) findMode(args["-mode"]),
- iterate: function (args) {
- for (let map in mappings.iterate(this.getMode(args)))
- for (let name in values(map.names))
- yield { name: name, __proto__: map };
- },
- format: {
- description: function (map) (XML.ignoreWhitespace = false, XML.prettyPrinting = false, <>
- {options.get("passkeys").has(map.name)
- ? <span highlight="URLExtra">({
- tempate.linkifyHelp(_("option.passkeys.passedBy"))
- })</span>
- : <></>}
- {template.linkifyHelp(map.description)}
- </>)
- }
- };
-
dactyl.addUsageCommand({
name: ["listo[ptions]", "lo"],
description: "List all options along with their short descriptions",
index: "option",
iterate: function (args) options,
format: {
- description: function (opt) (XML.ignoreWhitespace = false, XML.prettyPrinting = false, <>
- {opt.scope == Option.SCOPE_LOCAL
- ? <span highlight="URLExtra">({_("option.bufferLocal")})</span> : ""}
- {template.linkifyHelp(opt.description)}
- </>),
+ description: function (opt) [
+ opt.scope == Option.SCOPE_LOCAL
+ ? ["span", { highlight: "URLExtra" },
+ "(" + _("option.bufferLocal") + ")"]
+ : "",
+ template.linkifyHelp(opt.description)
+ ],
help: function (opt) "'" + opt.name + "'"
}
});
function fmt(value) (typeof value == "number" ? "#" :
typeof value == "function" ? "*" :
" ") + value;
- if (!args || args == "g:") {
- let str =
- <table>
- {
- template.map(globalVariables, function ([i, value]) {
- return <tr>
- <td style="width: 200px;">{i}</td>
- <td>{fmt(value)}</td>
- </tr>;
- })
- }
- </table>;
- if (str.text().length() == str.*.length())
- dactyl.echomsg(_("variable.none"));
- else
- dactyl.echo(str, modules.commandline.FORCE_MULTILINE);
- return;
- }
+ util.assert(!(!args || args == "g:"));
let matches = args.match(/^([a-z]:)?([\w]+)(?:\s*([-+.])?=\s*(.*)?)?$/);
if (matches) {