diff --git a/common/components/protocols.js b/common/components/protocols.js index f37a0ebf..0bedf607 100644 --- a/common/components/protocols.js +++ b/common/components/protocols.js @@ -23,16 +23,22 @@ const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPr function dataURL(type, data) "data:" + (type || "application/xml;encoding=UTF-8") + "," + escape(data); function makeChannel(url, orig) { - if (url == null) - return fakeChannel(); - if (typeof url === "function") - url = dataURL.apply(null, url()); - let uri = ioService.newURI(url, null, null); - let channel = ioService.newChannelFromURI(uri); - channel.contentCharset = "UTF-8"; - channel.owner = systemPrincipal; - channel.originalURI = orig; - return channel; + try { + if (url == null) + return fakeChannel(); + if (typeof url === "function") + url = dataURL.apply(null, url()); + let uri = ioService.newURI(url, null, null); + let channel = ioService.newChannelFromURI(uri); + channel.contentCharset = "UTF-8"; + channel.owner = systemPrincipal; + channel.originalURI = orig; + return channel; + } + catch (e) { + Components.utils.reportError(e); + throw e; + } } function fakeChannel(orig) makeChannel("chrome://dactyl/content/does/not/exist", orig); function redirect(to, orig, time) { diff --git a/common/content/commands.js b/common/content/commands.js index 63df6d03..8bd700d7 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -448,6 +448,10 @@ const Commands = Module("commands", { /** @property {Iterator(Command)} @private */ __iterator__: function () { + let sorted = this._exCommands.sort(function (a, b) a.name > b.name); + return array.iterValues(sorted); + }, + iterator: function () { let sorted = this._exCommands.sort(function (a, b) a.serialGroup - b.serialGroup || a.name > b.name); return array.iterValues(sorted); }, diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 7690f32f..dbebe862 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -564,6 +564,8 @@ const Dactyl = Module("dactyl", { .toXMLString())); fileMap["plugins"] = function () ['text/xml;charset=UTF-8', help]; + default xml namespace = NS; + overlayMap["index"] = function () ['text/xml;charset=UTF-8', '\n' + '\n' + @@ -571,8 +573,7 @@ const Dactyl = Module("dactyl", { template.map(dactyl.indices, function ([name, iter])
{ template.map(iter(), util.identity) - }
, <>{"\n\n"}))) - .replace('xmlns="' + XHTML + '"', "", "g") + + }, <>{"\n\n"}))) + '\n
']; addTags("plugins", util.httpGet("dactyl://help/plugins").responseXML); @@ -728,33 +729,36 @@ const Dactyl = Module("dactyl", { XML.prettyPrinting = false; XML.ignoreWhitespace = false; + default xml namespace = NS; // E4X has its warts. let br = <> ; let res = -
{link(obj.name)}
{obj.description ? obj.description.replace(/\.$/, "") : ""}
; +
{link(obj.name)}
{ + template.linkifyHelp(obj.description ? obj.description.replace(/\.$/, "") : "", true) + }
; if (specOnly) return res.*; res.* += <> - - {template.map(obj.names.slice().reverse(), tag, " ")} - { - spec(template.highlightRegexp((obj.specs || obj.names)[0], - /\[(.*?)\]/g, - function (m, n0) {n0})) - }{ - !obj.type ? "" : <> - {obj.type} - {obj.stringDefaultValue}} - { - obj.description ? br +

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

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

Sorry, no help available.

: "" } -
-
; + + {template.map(obj.names.slice().reverse(), tag, " ")} + { + spec(template.highlightRegexp((obj.specs || obj.names)[0], + /\[(.*?)\]/g, + function (m, n0) {n0})) + }{ + !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 + @@ -779,7 +783,10 @@ const Dactyl = Module("dactyl", { }) } ])); - return res.*.toXMLString().replace(/^ {12}|[ \t]+$/gm, "").replace(/^.*\n|\n.*$/g, "") + "\n"; + return res.*.toXMLString() + .replace(' xmlns="' + NS + '"', "", "g") + .replace(/^ {12}|[ \t]+$/gm, "") + .replace(/^\s*\n|\n\s*$/g, "") + "\n"; }, /** @@ -1798,10 +1805,10 @@ const Dactyl = Module("dactyl", { keepQuotes: true, serialGroup: 10, serialize: function () [ - { - command: this.name, - literalArg: options["loadplugins"].join(" ") - } + { + command: this.name, + literalArg: options["loadplugins"].join(" ") + } ] }); diff --git a/common/content/io.js b/common/content/io.js index 55a302a9..dc5eae04 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -555,7 +555,7 @@ lookup: "E189: " + filename.quote() + " exists (add ! to override)"); // TODO: Use a set/specifiable list here: - let lines = [cmd.serialize().map(commands.commandToString, cmd) for (cmd in commands) if (cmd.serialize)]; + let lines = [cmd.serialize().map(commands.commandToString, cmd) for (cmd in commands.iterator()) if (cmd.serialize)]; lines = array.flatten(lines); lines.unshift('"' + dactyl.version + "\n"); diff --git a/common/modules/template.jsm b/common/modules/template.jsm index bdb2b8b3..4bcfeee3 100644 --- a/common/modules/template.jsm +++ b/common/modules/template.jsm @@ -88,6 +88,16 @@ const Template = Module("Template", { /^:\w/.test(topic) ? "HelpEx" : "HelpKey"); return {text || topic} }, + HelpLink: function (topic) { + if (services["dactyl:"].initialized && !set.has(services["dactyl:"].HELP_TAGS, topic)) + return <>{topic}; + + XML.ignoreWhitespace = false; XML.prettyPrinting = false; + let tag = (/^'.*'$/.test(topic) ? "o" : + /^:\w/.test(topic) ? "ex" : "k"); + topic = topic.replace(/^'(.*)'$/, "$1"); + return <{tag} xmlns={NS}>{topic} + }, // if "processStrings" is true, any passed strings will be surrounded by " and // any line breaks are displayed as \n @@ -210,7 +220,7 @@ const Template = Module("Template", { // }, - linkifyHelp: function linkifyHelp(str) { + linkifyHelp: function linkifyHelp(str, help) { util.dactyl.initHelp(); let re = util.regexp(