X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=common%2Fmodules%2Foptions.jsm;fp=common%2Fmodules%2Foptions.jsm;h=1440e23cd6e7b0ad6d5dc4abc944db69fed729ce;hb=10dd809e3c62dac9afcb5592982306ab22198f65;hp=dacafbdd28b282cc3e9879e3c6c7871ceff749aa;hpb=c8bcbfcd3f674388aa15b4096ce2c5ed6f91238b;p=dactyl.git diff --git a/common/modules/options.jsm b/common/modules/options.jsm index dacafbd..1440e23 100644 --- a/common/modules/options.jsm +++ b/common/modules/options.jsm @@ -4,17 +4,22 @@ // // 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 */ @@ -849,35 +854,38 @@ var Options = Module("options", { 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)), - <>, )}; + 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() { @@ -1063,36 +1071,19 @@ var Options = Module("options", { 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) - ? ({ - tempate.linkifyHelp(_("option.passkeys.passedBy")) - }) - : <>} - {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 - ? ({_("option.bufferLocal")}) : ""} - {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 + "'" } }); @@ -1304,24 +1295,7 @@ var Options = Module("options", { function fmt(value) (typeof value == "number" ? "#" : typeof value == "function" ? "*" : " ") + value; - if (!args || args == "g:") { - let str = - - { - template.map(globalVariables, function ([i, value]) { - return - - - ; - }) - } -
{i}{fmt(value)}
; - 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) {