1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-14 07:55:48 +01:00

Death to E4X and stuff.

This commit is contained in:
Kris Maglione
2012-11-27 22:57:45 -08:00
parent 6200b08c13
commit a0f0668166
5 changed files with 104 additions and 36 deletions

View File

@@ -262,33 +262,29 @@ var Abbreviations = Module("abbreviations", {
function abbrevs(hive)
hive.merged.filter(function (abbr) (abbr.inModes(modes) && abbr.lhs.indexOf(lhs) == 0));
let list = <table>
<tr highlight="Title">
<td/>
<td style="padding-right: 1em;">{_("title.Mode")}</td>
<td style="padding-right: 1em;">{_("title.Abbrev")}</td>
<td style="padding-right: 1em;">{_("title.Replacement")}</td>
</tr>
<col style="min-width: 6em; padding-right: 1em;"/>
{
template.map(hives, function (hive) let (i = 0)
<tr style="height: .5ex;"/> +
template.map(abbrevs(hive), function (abbrev)
<tr>
<td highlight="Title">{!i++ ? hive.name : ""}</td>
<td>{abbrev.modeChar}</td>
<td>{abbrev.lhs}</td>
<td>{abbrev.rhs}</td>
</tr>) +
<tr style="height: .5ex;"/>)
}
</table>;
let list = ["table", {},
["tr", { highlight: "Title" },
["td"],
["td", { style: "padding-right: 1em;" }, _("title.Mode")],
["td", { style: "padding-right: 1em;" }, _("title.Abbrev")],
["td", { style: "padding-right: 1em;" }, _("title.Replacement")]],
["col", { style: "min-width: 6em; padding-right: 1em;" }],
hives.map(function (hive) let (i = 0) [
["tr", { style: "height: .5ex;" }],
abbrevs(hive).map(function (abbrev)
["tr", {},
["td", { highlight: "Title" }, !i++ ? String(hive.name) : ""],
["td", {}, abbrev.modeChar],
["td", {}, abbrev.lhs],
["td", {}, abbrev.rhs]]),
["tr", { style: "height: .5ex;" }]])];
// TODO: Move this to an ItemList to show this automatically
if (list.*.length() === list.text().length() + 2)
dactyl.echomsg(_("abbreviation.none"));
else
commandline.commandOutput(list);
// FIXME?
// // TODO: Move this to an ItemList to show this automatically
// if (list.*.length() === list.text().length() + 2)
// dactyl.echomsg(_("abbreviation.none"));
// else
commandline.commandOutput(list);
}
}, {

View File

@@ -665,10 +665,14 @@ var CommandLine = Module("commandline", {
*/
commandOutput: function commandOutput(xml) {
XML.ignoreWhitespace = XML.prettyPrinting = false;
if (this.command)
this.echo(<><div xmlns={XHTML}>:{this.command}</div>&#x0d;{xml}</>, this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE);
else
if (!this.command)
this.echo(xml, this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE);
else if (isXML(xml))
this.echo(<><div xmlns={XHTML}>:{this.command}</div>&#x0d;{xml}</>,
this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE);
else
this.echo([["div", { xmlns: "html" }, ":" + this.command], "\n", xml],
this.HIGHLIGHT_NORMAL, this.FORCE_MULTILINE);
this.command = null;
},
@@ -699,7 +703,7 @@ var CommandLine = Module("commandline", {
let field = this.widgets.active.message.inputField;
if (field.value && !forceSingle && field.editor.rootElement.scrollWidth > field.scrollWidth) {
this.widgets.message = null;
mow.echo(<span highlight="Message">{str}</span>, highlightGroup, true);
mow.echo(["span", { highlight: "Message" }, str], highlightGroup, true);
}
},
@@ -737,7 +741,7 @@ var CommandLine = Module("commandline", {
highlightGroup = highlightGroup || this.HL_NORMAL;
if (flags & this.APPEND_TO_MESSAGES) {
let message = isObject(data) ? data : { message: data };
let message = isObject(data) && !DOM.isJSONXML(data) ? data : { message: data };
// Make sure the memoized message property is an instance property.
message.message;

View File

@@ -112,7 +112,7 @@ var MOW = Module("mow", {
highlightGroup = "CommandOutput " + (highlightGroup || "");
if (isObject(data) && !isinstance(data, _)) {
if (isObject(data) && !isinstance(data, _) && !DOM.isJSONXML(data)) {
this.lastOutput = null;
var output = DOM(["div", { style: "white-space: nowrap", highlight: highlightGroup }],
@@ -127,9 +127,16 @@ var MOW = Module("mow", {
}
this.messages.push(data);
}
else if (DOM.isJSONXML(data) || isString(data)) {
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 = <div style={"white-space: " + style} highlight={highlightGroup}>{data}</div>;
this.lastOutput = <div style="white-space: nowrap" highlight={highlightGroup}>{data}</div>;
var output = DOM(this.lastOutput, this.document);
}