diff --git a/common/content/commandline.js b/common/content/commandline.js index 4144f368..db8f6455 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -4,7 +4,7 @@ // // 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"; /** @scope modules */ @@ -664,12 +664,8 @@ var CommandLine = Module("commandline", { * @param {XML} xml The output as an E4X XML object. */ commandOutput: function commandOutput(xml) { - XML.ignoreWhitespace = XML.prettyPrinting = false; if (!this.command) this.echo(xml, this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE); - else if (isXML(xml)) - this.echo(<>
:{this.command}
{xml}, - this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE); else this.echo([["div", { xmlns: "html" }, ":" + this.command], "\n", xml], this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE); @@ -765,7 +761,7 @@ var CommandLine = Module("commandline", { this._lastEcho = null; else { if (this.widgets.message && this.widgets.message[1] == this._lastEcho) - mow.echo({this._lastEcho}, + mow.echo(["span", { highlight: "Message" }, this._lastEcho], this.widgets.message[0], true); if (action === this._echoLine && !(flags & this.FORCE_MULTILINE) @@ -1624,10 +1620,10 @@ var CommandLine = Module("commandline", { commandline.echo(message.message, message.highlight, commandline.FORCE_SINGLELINE); } else if (commandline._messageHistory.length > 1) { - XML.ignoreWhitespace = false; commandline.commandOutput( - template.map(commandline._messageHistory.messages, function (message) -
{message.message}
)); + template_.map(commandline._messageHistory.messages, function (message) + ["div", { highlight: message.highlight + " Message" }, + message.message])); } }, { argCount: "0" }); diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 780a1c57..529e74bd 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -4,7 +4,7 @@ // // 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"; /** @scope modules */ @@ -281,7 +281,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { for (let obj in values(results)) { let res = dactyl.generateHelp(obj, null, null, true); if (!haveTag(obj.helpTag)) - res[1].@tag = obj.helpTag; + res[0][1].tag = obj.helpTag; yield res; } @@ -418,7 +418,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { if (isObject(str) && "echoerr" in str) str = str.echoerr; else if (isinstance(str, ["Error", FailedAssertion]) && str.fileName) - str = util.Magic([str.fileName.replace(/^.* -> /, ""), ": ", str.lineNumber, ": ", str].join("")); + str = [str.fileName.replace(/^.* -> /, ""), ": ", str.lineNumber, ": ", str].join(""); if (options["errorbells"]) dactyl.beep(); @@ -661,110 +661,6 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { * @returns {string} */ generateHelp: function generateHelp(obj, extraHelp, str, specOnly) { - default xml namespace = ""; - - let link, tag, spec; - link = tag = spec = util.identity; - let args = null; - - if (obj instanceof Command) { - link = function (cmd) {cmd}; - args = obj.parseArgs("", CompletionContext(str || "")); - tag = function (cmd) <>:{cmd}; - spec = function (cmd) <>{ - obj.count ? count : <> - }{ - cmd - }{ - obj.bang ? ! : <> - }; - } - else if (obj instanceof Map) { - spec = function (map) obj.count ? <>count{map} : <>{map}; - tag = function (map) <>{ - let (c = obj.modes[0].char) c ? c + "_" : "" - }{ map }; - link = function (map) { - let [, mode, name, extra] = /^(?:(.)_)?(?:<([^>]+)>)?(.*)$/.exec(map); - let k = {extra}; - if (name) - k.@name = name; - if (mode) - k.@mode = mode; - return k; - }; - } - else if (obj instanceof Option) { - spec = function () template.map(obj.names, tag, " "); - tag = function (name) <>'{name}'; - link = function (opt, name) {name}; - args = { value: "", values: [] }; - } - - XML.prettyPrinting = false; - XML.ignoreWhitespace = false; - default xml namespace = NS; - - // E4X has its warts. - let br = <> - ; - - let res = -
{link(obj.helpTag || tag(obj.name), obj.name)}
{ - template.linkifyHelp(obj.description ? obj.description.replace(/\.$/, "") : "", true) - }
; - if (specOnly) - return res.elements(); - - res.* += <> - - {template.map(obj.names.slice().reverse(), tag, " ")} - {let (name = (obj.specs || obj.names)[0]) - spec(template.highlightRegexp(tag(name), - /\[(.*?)\]/g, - function (m, n0) {n0}), - name) - }{ - !obj.type ? "" : <> - {obj.type} - {obj.stringDefaultValue}} - { - obj.description ? br +

{template.linkifyHelp(obj.description.replace(/\.?$/, "."), true)}

: "" }{ - extraHelp ? br + extraHelp : "" }{ - !(extraHelp || obj.description) ? br +

Sorry, no help available.

: "" } -
-
; - - function add(ary) { - res.item.description.* += br + - let (br = br + <> ) - <>
{ br + template.map(ary, function ([a, b]) <>
{a}
{b}
, br) } -
- ; - } - - if (obj.completer) - add(completion._runCompleter(obj.closure.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) {n}, <>, ) - }) - } - ])); - return res.*.toXMLString() - .replace(' xmlns="' + NS + '"', "", "g") - .replace(/^ {12}|[ \t]+$/gm, "") - .replace(/^\s*\n|\n\s*$/g, "") + "\n"; - }, - - _generateHelp: function generateHelp(obj, extraHelp, str, specOnly) { let link, tag, spec; link = tag = spec = util.identity; let args = null; diff --git a/common/content/mow.js b/common/content/mow.js index 0aade542..1d880f10 100644 --- a/common/content/mow.js +++ b/common/content/mow.js @@ -4,7 +4,7 @@ // // 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"; var MOW = Module("mow", { init: function init() { @@ -104,12 +104,6 @@ var MOW = Module("mow", { this.messages = []; } - // If it's already XML, assume it knows what it's doing. - // Otherwise, white space is significant. - // The problem elsewhere is that E4X tends to insert new lines - // after interpolated data. - XML.ignoreWhitespace = XML.prettyPrinting = false; - highlightGroup = "CommandOutput " + (highlightGroup || ""); if (isObject(data) && !isinstance(data, _) && !DOM.isJSONXML(data)) { @@ -127,19 +121,13 @@ var MOW = Module("mow", { } this.messages.push(data); } - else if (DOM.isJSONXML(data) || isString(data)) { + else { let style = isString(data) ? "pre-wrap" : "nowrap"; this.lastOutput = ["div", { style: "white-space: " + style, highlight: highlightGroup }, data]; var output = DOM(this.lastOutput, this.document); } - else { - let style = isString(data) ? "pre-wrap" : "nowrap"; - this.lastOutput =
{data}
; - - var output = DOM(this.lastOutput, this.document); - } // FIXME: need to make sure an open MOW is closed when commands // that don't generate output are executed diff --git a/common/modules/template.jsm b/common/modules/template.jsm index aa4503cc..c127434c 100644 --- a/common/modules/template.jsm +++ b/common/modules/template.jsm @@ -666,7 +666,7 @@ var Template_ = Module("Template_", { return this.highlightSubstrings(str, (function () { for (let res in re.iterate(str)) yield [res.index + res.pre.length, res.tag.length]; - })(), template[help ? "HelpLink" : "helpLink"]); + })(), this[help ? "HelpLink" : "helpLink"]); }, @@ -779,7 +779,6 @@ var Template_ = Module("Template_", { break; _i = i; - XML.ignoreWhitespace = false; s.push(str.substring(start, i), highlight.apply(this, Array.concat(args || str.substr(i, length)))); start = i + length; diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 8c66f5c0..6a16628b 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -22,6 +22,8 @@ var Magic = Class("Magic", { this.str = str; }, + get message() this.str, + toString: function () this.str });