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

Death to E4X and stuff.

This commit is contained in:
Kris Maglione
2012-11-27 21:30:46 -08:00
parent 062d3f5ca4
commit 6200b08c13
8 changed files with 250 additions and 136 deletions

View File

@@ -14,56 +14,45 @@ var CommandWidgets = Class("CommandWidgets", {
init: function init() {
let s = "dactyl-statusline-field-";
XML.ignoreWhitespace = true;
overlay.overlayWindow(window, {
objects: {
eventTarget: commandline
},
append: <e4x xmlns={XUL} xmlns:dactyl={NS}>
<vbox id={config.ids.commandContainer}>
<vbox class="dactyl-container" hidden="false" collapsed="true">
<iframe class="dactyl-completions" id="dactyl-completions-dactyl-commandline" src="dactyl://content/buffer.xhtml"
contextmenu="dactyl-contextmenu"
flex="1" hidden="false" collapsed="false"
highlight="Events" events="mowEvents" />
</vbox>
append: [
["vbox", { id: config.ids.commandContainer, xmlns: "xul" },
["vbox", { class: "dactyl-container", hidden: "false", collapsed: "true" },
["iframe", { class: "dactyl-completions", id: "dactyl-completions-dactyl-commandline",
src: "dactyl://content/buffer.xhtml", contextmenu: "dactyl-contextmenu",
flex: "1", hidden: "false", collapsed: "false",
highlight: "Events", events: "mowEvents" }]],
<stack orient="horizontal" align="stretch" class="dactyl-container" id="dactyl-container" highlight="CmdLine CmdCmdLine">
<textbox class="plain" id="dactyl-strut" flex="1" crop="end" collapsed="true"/>
<textbox class="plain" id="dactyl-mode" flex="1" crop="end"/>
<textbox class="plain" id="dactyl-message" flex="1" readonly="true"/>
["stack", { orient: "horizontal", align: "stretch", class: "dactyl-container",
id: "dactyl-container", highlight: "CmdLine CmdCmdLine" },
["textbox", { class: "plain", id: "dactyl-strut", flex: "1", crop: "end", collapsed: "true" }],
["textbox", { class: "plain", id: "dactyl-mode", flex: "1", crop: "end" }],
["textbox", { class: "plain", id: "dactyl-message", flex: "1", readonly: "true" }],
<hbox id="dactyl-commandline" hidden="false" class="dactyl-container" highlight="Normal CmdNormal" collapsed="true">
<label id="dactyl-commandline-prompt" class="dactyl-commandline-prompt plain" flex="0" crop="end" value="" collapsed="true"/>
<textbox id="dactyl-commandline-command" class="dactyl-commandline-command plain" flex="1" type="input" timeout="100"
highlight="Events" />
</hbox>
</stack>
["hbox", { id: "dactyl-commandline", hidden: "false", foo: "bar", class: "dactyl-container", highlight: "Normal CmdNormal", collapsed: "true" },
["label", { id: "dactyl-commandline-prompt", class: "dactyl-commandline-prompt plain", flex: "0", crop: "end", value: "", collapsed: "true" }],
["textbox", { id: "dactyl-commandline-command", class: "dactyl-commandline-command plain", flex: "1", type: "input", timeout: "100",
highlight: "Events" }]]],
<vbox class="dactyl-container" hidden="false" collapsed="false" highlight="CmdLine">
<textbox id="dactyl-multiline-input" class="plain" flex="1" rows="1" hidden="false" collapsed="true" multiline="true"
highlight="Normal Events" events="multilineInputEvents" />
</vbox>
</vbox>
["vbox", { class: "dactyl-container", hidden: "false", collapsed: "false", highlight: "CmdLine" },
["textbox", { id: "dactyl-multiline-input", class: "plain", flex: "1", rows: "1", hidden: "false", collapsed: "true",
multiline: "true", highlight: "Normal Events", events: "multilineInputEvents" }]]],
<stack id="dactyl-statusline-stack">
<hbox id={s + "commandline"} hidden="false" class="dactyl-container" highlight="Normal StatusNormal" collapsed="true">
<label id={s + "commandline-prompt"} class="dactyl-commandline-prompt plain" flex="0" crop="end" value="" collapsed="true"/>
<textbox id={s + "commandline-command"} class="dactyl-commandline-command plain" flex="1" type="text" timeout="100"
highlight="Events" />
</hbox>
</stack>
</e4x>.elements(),
["stack", { id: "dactyl-statusline-stack", xmlns: "xul" },
["hbox", { id: s + "commandline", hidden: "false", class: "dactyl-container", highlight: "Normal StatusNormal", collapsed: "true" },
["label", { id: s + "commandline-prompt", class: "dactyl-commandline-prompt plain", flex: "0", crop: "end", value: "", collapsed: "true" }],
["textbox", { id: s + "commandline-command", class: "dactyl-commandline-command plain", flex: "1", type: "text", timeout: "100",
highlight: "Events", }]]]],
before: <e4x xmlns={XUL} xmlns:dactyl={NS}>
<toolbar id={statusline.statusBar.id}>
<vbox id={"dactyl-completions-" + s + "commandline-container"} class="dactyl-container" hidden="false" collapsed="true">
<iframe class="dactyl-completions" id={"dactyl-completions-" + s + "commandline"} src="dactyl://content/buffer.xhtml"
contextmenu="dactyl-contextmenu" flex="1" hidden="false" collapsed="false"
highlight="Events" events="mowEvents" />
</vbox>
</toolbar>
</e4x>.elements()
before: [
["toolbar", { id: statusline.statusBar.id, xmlns: "xul" },
["vbox", { id: "dactyl-completions-" + s + "commandline-container", class: "dactyl-container", hidden: "false", collapsed: "true" },
["iframe", { class: "dactyl-completions", id: "dactyl-completions-" + s + "commandline", src: "dactyl://content/buffer.xhtml",
contextmenu: "dactyl-contextmenu", flex: "1", hidden: "false", collapsed: "false", highlight: "Events",
events: "mowEvents" }]]]],
});
this.elements = {};

View File

@@ -304,20 +304,15 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
bell: document.getElementById("dactyl-bell"),
strut: document.getElementById("dactyl-bell-strut")
};
XML.ignoreWhitespace = true;
if (!elems.bell)
overlay.overlayWindow(window, {
objects: elems,
prepend: <>
<window id={document.documentElement.id} xmlns={XUL}>
<hbox style="display: none" highlight="Bell" id="dactyl-bell" key="bell"/>
</window>
</>,
append: <>
<window id={document.documentElement.id} xmlns={XUL}>
<hbox style="display: none" highlight="Bell" id="dactyl-bell-strut" key="strut"/>
</window>
</>
prepend: [
["window", { id: document.documentElement.id, xmlns: "xul" },
["hbox", { style: "display: none", highlight: "Bell", id: "dactyl-bell", key: "bell" }]]],
append: [
["window", { id: document.documentElement.id, xmlns: "xul" },
["hbox", { style: "display: none", highlight: "Bell", id: "dactyl-bell-strut", key: "strut" }]]]
}, elems);
elems.bell.style.height = window.innerHeight + "px";

View File

@@ -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 */
@@ -102,17 +102,14 @@ var Events = Module("events", {
init: function () {
this.keyEvents = [];
XML.ignoreWhitespace = true;
overlay.overlayWindow(window, {
append: <e4x xmlns={XUL}>
<window id={document.documentElement.id}>
<!-- http://developer.mozilla.org/en/docs/XUL_Tutorial:Updating_Commands -->
<commandset id="dactyl-onfocus" commandupdater="true" events="focus"
oncommandupdate="dactyl.modules.events.onFocusChange(event);"/>
<commandset id="dactyl-onselect" commandupdater="true" events="select"
oncommandupdate="dactyl.modules.events.onSelectionChange(event);"/>
</window>
</e4x>.elements()
append: [
["window", { id: document.documentElement.id, xmlns: "xul" },
// http://developer.mozilla.org/en/docs/XUL_Tutorial:Updating_Commands
["commandset", { id: "dactyl-onfocus", commandupdater: "true", events: "focus",
commandupdate: this.closure.onFocusChange }],
["commandset", { id: "dactyl-onselect", commandupdater: "true", events: "select",
commandupdate: this.closure.onSelectionChange }]]]
});
this._fullscreen = window.fullScreen;

View File

@@ -41,38 +41,28 @@ var MOW = Module("mow", {
html|html > xul|scrollbar { visibility: collapse !important; }",
true);
XML.ignoreWhitespace = true;
overlay.overlayWindow(window, {
objects: {
eventTarget: this
},
append: <e4x xmlns={XUL} xmlns:dactyl={NS}>
<window id={document.documentElement.id}>
<popupset>
<menupopup id="dactyl-contextmenu" highlight="Events" events="contextEvents">
<menuitem id="dactyl-context-copylink"
label={_("mow.contextMenu.copyLink")} dactyl:group="link"
oncommand="goDoCommand('cmd_copyLink');"/>
<menuitem id="dactyl-context-copypath"
label={_("mow.contextMenu.copyPath")} dactyl:group="link path"
oncommand="dactyl.clipboardWrite(document.popupNode.getAttribute('path'));"/>
<menuitem id="dactyl-context-copy"
label={_("mow.contextMenu.copy")} dactyl:group="selection"
command="cmd_copy"/>
<menuitem id="dactyl-context-selectall"
label={_("mow.contextMenu.selectAll")}
command="cmd_selectAll"/>
</menupopup>
</popupset>
</window>
<vbox id={config.ids.commandContainer}>
<vbox class="dactyl-container" id="dactyl-multiline-output-container" hidden="false" collapsed="true">
<iframe id="dactyl-multiline-output" src="dactyl://content/buffer.xhtml"
flex="1" hidden="false" collapsed="false" contextmenu="dactyl-contextmenu"
highlight="Events" />
</vbox>
</vbox>
</e4x>
append: [
["window", { id: document.documentElement.id, xmlns: "xul" },
["popupset", {},
["menupopup", { id: "dactyl-contextmenu", highlight: "Events", events: "contextEvents" },
["menuitem", { id: "dactyl-context-copylink", label: _("mow.contextMenu.copyLink"),
"dactyl:group": "link", oncommand: "goDoCommand('cmd_copyLink');" }],
["menuitem", { id: "dactyl-context-copypath", label: _("mow.contextMenu.copyPath"),
"dactyl:group": "link path", oncommand: "dactyl.clipboardWrite(document.popupNode.getAttribute('path'));" }],
["menuitem", { id: "dactyl-context-copy", label: _("mow.contextMenu.copy"),
"dactyl:group": "selection", command: "cmd_copy" }],
["menuitem", { id: "dactyl-context-selectall", label: _("mow.contextMenu.selectAll"),
command: "cmd_selectAll" }]]]],
["vbox", { id: config.ids.commandContainer, xmlns: "xul" },
["vbox", { class: "dactyl-container", id: "dactyl-multiline-output-container", hidden: "false", collapsed: "true" },
["iframe", { id: "dactyl-multiline-output", src: "dactyl://content/buffer.xhtml",
flex: "1", hidden: "false", collapsed: "false",
contextmenu: "dactyl-contextmenu", highlight: "Events" }]]]]
});
},
@@ -125,7 +115,7 @@ var MOW = Module("mow", {
if (isObject(data) && !isinstance(data, _)) {
this.lastOutput = null;
var output = DOM(<div style="white-space: nowrap" highlight={highlightGroup}/>,
var output = DOM(["div", { style: "white-space: nowrap", highlight: highlightGroup }],
this.document);
data.document = this.document;
try {

View File

@@ -22,7 +22,10 @@ var StatusLine = Module("statusline", {
#addon-bar > xul|toolbarspring { visibility: collapse; }
]]></css>);
overlay.overlayWindow(window, { append: <><statusbar id="status-bar" ordinal="0"/></> });
overlay.overlayWindow(window, {
append: [
["statusbar", { id: "status-bar", ordinal: "0" }]]
});
highlight.loadCSS(util.compileMacro(<![CDATA[
!AddonBar;#addon-bar {
@@ -52,39 +55,41 @@ var StatusLine = Module("statusline", {
XML.ignoreWhitespace = true;
let _commandline = "if (window.dactyl) return dactyl.modules.commandline";
let prepend = <e4x xmlns={XUL} xmlns:dactyl={NS}>
<button id="appmenu-button" label="" image="chrome://branding/content/icon16.png" highlight="AppmenuButton" />
<toolbarbutton id="appmenu-toolbar-button" label="" image="chrome://branding/content/icon16.png" />
<statusbar id="status-bar" highlight="StatusLine">
<!-- insertbefore="dactyl.statusBefore;" insertafter="dactyl.statusAfter;" -->
<hbox key="container" hidden="false" align="center" flex="1">
<stack orient="horizontal" align="stretch" flex="1" highlight="CmdLine StatusCmdLine" class="dactyl-container">
<hbox highlight="CmdLine StatusCmdLine" class="dactyl-container">
<label key="mode" crop="end" class="plain" collapsed="true"/>
<stack id="dactyl-statusline-stack" flex="1" highlight="CmdLine StatusCmdLine" class="dactyl-container">
<textbox key="url" crop="end" flex="1" style="background: transparent;" class="plain dactyl-status-field-url" readonly="true"/>
<textbox key="message" crop="end" flex="1" highlight="Normal StatusNormal" class="plain" readonly="true"/>
</stack>
</hbox>
</stack>
<label class="plain" key="inputbuffer" flex="0"/>
<label class="plain" key="progress" flex="0"/>
<label class="plain" key="tabcount" flex="0"/>
<label class="plain" key="bufferposition" flex="0"/>
<label class="plain" key="zoomlevel" flex="0"/>
</hbox>
<!-- just hide them since other elements expect them -->
<statusbarpanel id="statusbar-display" hidden="true"/>
<statusbarpanel id="statusbar-progresspanel" hidden="true"/>
</statusbar>
</e4x>;
let prepend = [
["button", { id: "appmenu-button", label: "", image: "chrome://branding/content/icon16.png", highlight: "AppmenuButton", xmlns: "xul" }],
["toolbarbutton", { id: "appmenu-toolbar-button", label: "", image: "chrome://branding/content/icon16.png" }],
["statusbar", { id: "status-bar", highlight: "StatusLine", xmlns: "xul" },
// <!-- insertbefore="dactyl.statusBefore;" insertafter="dactyl.statusAfter;" -->
["hbox", { key: "container", hidden: "false", align: "center", flex: "1" },
["stack", { orient: "horizontal", align: "stretch", flex: "1", highlight: "CmdLine StatusCmdLine", class: "dactyl-container" },
["hbox", { highlight: "CmdLine StatusCmdLine", class: "dactyl-container" },
["label", { key: "mode", crop: "end", class: "plain", collapsed: "true" }],
["stack", { id: "dactyl-statusline-stack", flex: "1", highlight: "CmdLine StatusCmdLine", class: "dactyl-container" },
["textbox", { key: "url", crop: "end", flex: "1", style: "background: transparent;", class: "plain dactyl-status-field-url",
readonly: "true" }],
["textbox", { key: "message", crop: "end", flex: "1", highlight: "Normal StatusNormal", class: "plain",
readonly: "true" }]]]],
["label", { class: "plain", key: "inputbuffer", flex: "0" }],
["label", { class: "plain", key: "progress", flex: "0" }],
["label", { class: "plain", key: "tabcount", flex: "0" }],
["label", { class: "plain", key: "bufferposition", flex: "0" }],
["label", { class: "plain", key: "zoomlevel", flex: "0" }]],
// just hide them since other elements expect them
["statusbarpanel", { id: "statusbar-display", hidden: "true" }],
["statusbarpanel", { id: "statusbar-progresspanel", hidden: "true" }]]];
for each (let attr in prepend..@key)
attr.parent().@id = "dactyl-statusline-field-" + attr;
(function rec(ary) {
ary.forEach(function (elem) {
if ("key" in elem[1])
elem[1].id = "dactyl-statusline-field-" + elem[1].key;
if (elem.length > 2)
rec(elem.slice(2));
});
})(prepend);
overlay.overlayWindow(window, {
objects: this.widgets = { get status() this.container },
prepend: prepend.elements()
prepend: prepend
});
try {