mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-04 05:14:12 +01:00
Preparation for a future commit and fix ;F in the MOW.
This commit is contained in:
@@ -110,26 +110,6 @@ const CommandLine = Module("commandline", {
|
||||
this._startHints = false; // whether we're waiting to start hints mode
|
||||
this._lastSubstring = "";
|
||||
|
||||
memoize(this, "widgets", function () {
|
||||
let widgets = {
|
||||
commandline: document.getElementById("dactyl-commandline"),
|
||||
prompt: document.getElementById("dactyl-commandline-prompt"),
|
||||
command: document.getElementById("dactyl-commandline-command"),
|
||||
|
||||
message: document.getElementById("dactyl-message"),
|
||||
|
||||
multilineOutput: document.getElementById("dactyl-multiline-output"),
|
||||
multilineInput: document.getElementById("dactyl-multiline-input")
|
||||
};
|
||||
|
||||
widgets.command.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
|
||||
widgets.message.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
|
||||
widgets.mowContainer = widgets.multilineOutput.parentNode;
|
||||
|
||||
widgets.multilineOutput.contentDocument.body.id = "dactyl-multiline-output-content";
|
||||
return widgets;
|
||||
});
|
||||
|
||||
// we need to save the mode which were in before opening the command line
|
||||
// this is then used if we focus the command line again without the "official"
|
||||
// way of calling "open"
|
||||
@@ -344,6 +324,26 @@ const CommandLine = Module("commandline", {
|
||||
}, this);
|
||||
},
|
||||
|
||||
widgets: Class.memoize(function () {
|
||||
let widgets = {
|
||||
commandline: document.getElementById("dactyl-commandline"),
|
||||
prompt: document.getElementById("dactyl-commandline-prompt"),
|
||||
command: document.getElementById("dactyl-commandline-command"),
|
||||
|
||||
message: document.getElementById("dactyl-message"),
|
||||
|
||||
multilineOutput: document.getElementById("dactyl-multiline-output"),
|
||||
multilineInput: document.getElementById("dactyl-multiline-input")
|
||||
};
|
||||
|
||||
widgets.command.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
|
||||
widgets.message.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
|
||||
widgets.mowContainer = widgets.multilineOutput.parentNode;
|
||||
|
||||
widgets.multilineOutput.contentDocument.body.id = "dactyl-multiline-output-content";
|
||||
return widgets;
|
||||
}),
|
||||
|
||||
// @param type can be:
|
||||
// "submit": when the user pressed enter in the command line
|
||||
// "change"
|
||||
|
||||
@@ -127,8 +127,7 @@ const ConfigBase = Class(ModuleBase, {
|
||||
*/
|
||||
scripts: [],
|
||||
|
||||
get tabStrip()
|
||||
Class.replaceProperty(this, "tabStrip", document.getElementById("TabsToolbar") || this.tabbrowser.mTabContainer),
|
||||
tabStrip: Class.memoize(function () document.getElementById("TabsToolbar") || this.tabbrowser.mTabContainer),
|
||||
|
||||
/**
|
||||
* @property {string} The leaf name of any temp files created by
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
|
||||
<?xml-stylesheet href="chrome://dactyl/skin/dactyl.css" type="text/css"?>
|
||||
<!DOCTYPE overlay SYSTEM "dactyl.dtd" [
|
||||
<!ENTITY dactyl.content "chrome://dactyl/content/">
|
||||
<!ENTITY and "&&">
|
||||
<!ENTITY dactyl.content "chrome://dactyl/content/">
|
||||
<!ENTITY commandline "window.dactyl ∧ dactyl.modules.commandline">
|
||||
<!ENTITY events "if (window.dactyl ∧ dactyl.modules.loaded.events) dactyl.modules.events">
|
||||
<!ENTITY status "dactyl-statusline-field-">
|
||||
]>
|
||||
|
||||
<overlay id="dactyl"
|
||||
@@ -24,8 +27,8 @@
|
||||
|
||||
<window id="&dactyl.mainWindow;">
|
||||
<keyset id="mainKeyset">
|
||||
<key id="key_open_vimbar" key=":" oncommand="window.dactyl ∧ dactyl.modules.commandline.open(':', '', dactyl.modules.modes.EX);" modifiers=""/>
|
||||
<key id="key_stop" keycode="VK_ESCAPE" oncommand="window.dactyl ∧ dactyl.modules.events.onEscape();"/>
|
||||
<!-- Why do we need this? ––Kris -->
|
||||
<key id="key_stop" keycode="VK_ESCAPE" oncommand="&events;.onEscape();"/>
|
||||
<!-- other keys are handled inside the event loop in events.js -->
|
||||
</keyset>
|
||||
|
||||
@@ -35,61 +38,68 @@
|
||||
|
||||
<!--this notifies us also of focus events in the XUL
|
||||
from: http://developer.mozilla.org/en/docs/XUL_Tutorial:Updating_Commands !-->
|
||||
<commandset id="onPentadactylFocus"
|
||||
commandupdater="true"
|
||||
events="focus"
|
||||
oncommandupdate="if (window.dactyl ∧ dactyl.modules.loaded.events) dactyl.modules.events.onFocusChange(event);"/>
|
||||
<commandset id="onPentadactylSelect"
|
||||
commandupdater="true"
|
||||
events="select"
|
||||
oncommandupdate="if (window.dactyl ∧ dactyl.modules.loaded.events) dactyl.modules.events.onSelectionChange(event);"/>
|
||||
<!-- I don't think we really need this. ––Kris -->
|
||||
<commandset id="onPentadactylFocus" commandupdater="true" events="focus"
|
||||
oncommandupdate="&events;.onFocusChange(event);"/>
|
||||
<commandset id="onPentadactylSelect" commandupdater="true" events="select"
|
||||
oncommandupdate="&events;.onSelectionChange(event);"/>
|
||||
|
||||
<!-- As of Firefox 3.1pre, iframe.height changes do not seem to have immediate effect,
|
||||
therefore we need to put them into a <vbox> for which that works just fine -->
|
||||
<vbox class="dactyl-container" hidden="false" collapsed="true">
|
||||
<iframe id="dactyl-multiline-output" src="chrome://dactyl/content/buffer.xhtml"
|
||||
flex="1" hidden="false" collapsed="false"
|
||||
onclick="window.dactyl ∧ dactyl.modules.commandline.onMultilineOutputEvent(event)"/>
|
||||
onclick="&commandline;.onMultilineOutputEvent(event)"/>
|
||||
</vbox>
|
||||
|
||||
<vbox class="dactyl-container" hidden="false" collapsed="true">
|
||||
<iframe id="dactyl-completions" src="chrome://dactyl/content/buffer.xhtml"
|
||||
flex="1" hidden="false" collapsed="false"
|
||||
onclick="window.dactyl ∧ dactyl.modules.commandline.onMultilineOutputEvent(event)"/>
|
||||
onclick="&commandline;.onMultilineOutputEvent(event)"/>
|
||||
</vbox>
|
||||
|
||||
<stack orient="horizontal" align="stretch" class="dactyl-container" dactyl:highlight="CmdLine">
|
||||
<textbox class="plain" id="dactyl-mode" flex="1" readonly="true" dactyl:highlight="Normal"/>
|
||||
<textbox class="plain" id="dactyl-message" flex="1" readonly="true" dactyl:highlight="Normal"/>
|
||||
<hbox id="dactyl-commandline" hidden="false" collapsed="true" class="dactyl-container" dactyl:highlight="Normal">
|
||||
<label class="plain" id="dactyl-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
|
||||
|
||||
<hbox id="dactyl-commandline" hidden="false" class="dactyl-container" dactyl:highlight="Normal" collapsed="true">
|
||||
<label class="plain" id="dactyl-commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
|
||||
<textbox class="plain" id="dactyl-commandline-command" flex="1" type="search" timeout="100"
|
||||
oninput="window.dactyl ∧ dactyl.modules.commandline.onEvent(event);"
|
||||
onkeyup="window.dactyl ∧ dactyl.modules.commandline.onEvent(event);"
|
||||
onfocus="window.dactyl ∧ dactyl.modules.commandline.onEvent(event);"
|
||||
onblur="window.dactyl ∧ dactyl.modules.commandline.onEvent(event);"/>
|
||||
oninput="&commandline;.onEvent(event);" onkeyup="&commandline;.onEvent(event);"
|
||||
onfocus="&commandline;.onEvent(event);" onblur="&commandline;.onEvent(event);"/>
|
||||
</hbox>
|
||||
</stack>
|
||||
|
||||
<vbox class="dactyl-container" hidden="false" collapsed="false" dactyl:highlight="CmdLine">
|
||||
<textbox id="dactyl-multiline-input" class="plain" flex="1" rows="1" hidden="false" collapsed="true" multiline="true" dactyl:highlight="Normal"
|
||||
onkeypress="window.dactyl ∧ dactyl.modules.commandline.onMultilineInputEvent(event);"
|
||||
oninput="window.dactyl ∧ dactyl.modules.commandline.onMultilineInputEvent(event);"
|
||||
onblur="window.dactyl ∧ dactyl.modules.commandline.onMultilineInputEvent(event);"/>
|
||||
onkeypress="&commandline;.onMultilineInputEvent(event);" oninput="&commandline;.onMultilineInputEvent(event);"
|
||||
onblur="&commandline;.onMultilineInputEvent(event);"/>
|
||||
</vbox>
|
||||
</window>
|
||||
|
||||
<statusbar id="status-bar" dactyl:highlight="StatusLine">
|
||||
<hbox insertbefore="&dactyl.statusBefore;" insertafter="&dactyl.statusAfter;"
|
||||
id="dactyl-statusline-field-status" flex="1" hidden="false" align="center">
|
||||
<textbox class="plain" id="dactyl-statusline-field-url" readonly="false" flex="1" crop="end"/>
|
||||
<label class="plain" id="dactyl-statusline-field-inputbuffer" flex="0"/>
|
||||
<label class="plain" id="dactyl-statusline-field-progress" flex="0"/>
|
||||
<label class="plain" id="dactyl-statusline-field-tabcount" flex="0"/>
|
||||
<label class="plain" id="dactyl-statusline-field-bufferposition" flex="0"/>
|
||||
<label class="plain" id="dactyl-statusline-field-zoomlevel" flex="0"/>
|
||||
id="&status;status" flex="1" hidden="false" align="center">
|
||||
<stack orient="horizontal" align="stretch" flex="1" class="dactyl-container" dactyl:highlight="CmdLine">
|
||||
<textbox class="plain" id="&status;url" flex="1" readonly="false" crop="end"/>
|
||||
<textbox class="plain" id="&status;mode" flex="1" readonly="true" collapsed="true" dactyl:highlight="Normal"/>
|
||||
<textbox class="plain" id="&status;message" flex="1" readonly="true" collapsed="true" dactyl:highlight="Normal"/>
|
||||
|
||||
<hbox id="&status;commandline" hidden="false" class="dactyl-container" dactyl:highlight="Normal" collapsed="true">
|
||||
<label class="plain" id="&status;commandline-prompt" flex="0" crop="end" value="" collapsed="true"/>
|
||||
<textbox class="plain" id="&status;commandline-command" flex="1" type="search" timeout="100"
|
||||
oninput="&commandline;.onEvent(event);" onkeyup="&commandline;.onEvent(event);"
|
||||
onfocus="&commandline;.onEvent(event);" onblur="&commandline;.onEvent(event);"/>
|
||||
</hbox>
|
||||
</stack>
|
||||
<label class="plain" id="&status;inputbuffer" flex="0"/>
|
||||
<label class="plain" id="&status;progress" flex="0"/>
|
||||
<label class="plain" id="&status;tabcount" flex="0"/>
|
||||
<label class="plain" id="&status;bufferposition" flex="0"/>
|
||||
<label class="plain" id="&status;zoomlevel" flex="0"/>
|
||||
</hbox>
|
||||
<!-- just hide them since other elements expect them -->
|
||||
<statusbarpanel id="statusbar-display" hidden="true"/>
|
||||
<statusbarpanel id="statusbar-display" hidden="true"/>
|
||||
<statusbarpanel id="statusbar-progresspanel" hidden="true"/>
|
||||
</statusbar>
|
||||
</overlay>
|
||||
|
||||
@@ -33,9 +33,8 @@ const Hints = Module("hints", {
|
||||
|
||||
this._resizeTimer = Timer(100, 500, function () {
|
||||
if (self._top && (modes.extended & modes.HINTS)) {
|
||||
let win = self._top;
|
||||
self._removeHints(0, true);
|
||||
self._generate(win);
|
||||
self._generate(self._top);
|
||||
self._showHints();
|
||||
}
|
||||
});
|
||||
@@ -55,7 +54,7 @@ const Hints = Module("hints", {
|
||||
this.addMode("t", "Follow hint in a new tab", function (elem) buffer.followLink(elem, dactyl.NEW_TAB));
|
||||
this.addMode("b", "Follow hint in a background tab", function (elem) buffer.followLink(elem, dactyl.NEW_BACKGROUND_TAB));
|
||||
this.addMode("w", "Follow hint in a new window", function (elem) buffer.followLink(elem, dactyl.NEW_WINDOW));
|
||||
this.addMode("F", "Open multiple hints in tabs", function (elem) { buffer.followLink(elem, dactyl.NEW_BACKGROUND_TAB); hints.show("F"); });
|
||||
this.addMode("F", "Open multiple hints in tabs", function (elem, l, c, top) { buffer.followLink(elem, dactyl.NEW_BACKGROUND_TAB); hints.show("F", null, top); });
|
||||
this.addMode("O", "Generate an ':open URL' using hint", function (elem, loc) commandline.open(":", "open " + loc, modes.EX));
|
||||
this.addMode("T", "Generate a ':tabopen URL' using hint", function (elem, loc) commandline.open(":", "tabopen " + loc, modes.EX));
|
||||
this.addMode("W", "Generate a ':winopen URL' using hint", function (elem, loc) commandline.open(":", "winopen " + loc, modes.EX));
|
||||
@@ -247,10 +246,6 @@ const Hints = Module("hints", {
|
||||
_generate: function (win) {
|
||||
if (!win)
|
||||
win = window.content;
|
||||
if (!this._top) {
|
||||
this._top = win;
|
||||
win.addEventListener("resize", this._resizeTimer.closure.tell, true);
|
||||
}
|
||||
|
||||
let doc = win.document;
|
||||
let height = win.innerHeight;
|
||||
@@ -419,10 +414,6 @@ const Hints = Module("hints", {
|
||||
_removeHints: function (timeout, slight) {
|
||||
let firstElem = this._validHints[0] || null;
|
||||
|
||||
if (this._top)
|
||||
this._top.removeEventListener("resize", this._resizeTimer.closure.tell, true);
|
||||
this._top = null;
|
||||
|
||||
for (let [,{ doc: doc, start: start, end: end }] in Iterator(this._docs)) {
|
||||
for (let elem in util.evaluateXPath("//*[@dactyl:highlight='hints']", doc))
|
||||
elem.parentNode.removeChild(elem);
|
||||
@@ -481,6 +472,7 @@ const Hints = Module("hints", {
|
||||
let timeout = followFirst || events.feedingKeys ? 0 : 500;
|
||||
let activeIndex = (this._hintNumber ? this._hintNumber - 1 : 0);
|
||||
let elem = this._validHints[activeIndex];
|
||||
let top = this._top;
|
||||
this._removeHints(timeout);
|
||||
|
||||
if (timeout == 0)
|
||||
@@ -490,7 +482,7 @@ const Hints = Module("hints", {
|
||||
this.timeout(function () {
|
||||
if (modes.extended & modes.HINTS)
|
||||
modes.pop();
|
||||
this._hintMode.action(elem, elem.href || "", this._extendedhintCount);
|
||||
this._hintMode.action(elem, elem.href || "", this._extendedhintCount, top);
|
||||
}, timeout);
|
||||
return true;
|
||||
},
|
||||
@@ -772,6 +764,9 @@ const Hints = Module("hints", {
|
||||
this.prevInput = "";
|
||||
this._canUpdate = false;
|
||||
|
||||
this._top = win || content;
|
||||
this._top.addEventListener("resize", this._resizeTimer.closure.tell, true);
|
||||
|
||||
this._generate(win);
|
||||
|
||||
// get all keys from the input queue
|
||||
@@ -794,6 +789,10 @@ const Hints = Module("hints", {
|
||||
* Cancel all hinting.
|
||||
*/
|
||||
hide: function () {
|
||||
if (this._top)
|
||||
this._top.removeEventListener("resize", this._resizeTimer.closure.tell, true);
|
||||
this._top = null;
|
||||
|
||||
this._removeHints(0);
|
||||
},
|
||||
|
||||
@@ -911,7 +910,7 @@ const Hints = Module("hints", {
|
||||
|
||||
//}}}
|
||||
}, {
|
||||
get translitTable() function () {
|
||||
translitTable: Class.memoize(function () {
|
||||
const table = {};
|
||||
[
|
||||
[0x00c0, 0x00c6, ["A"]], [0x00c7, 0x00c7, ["C"]],
|
||||
@@ -978,19 +977,17 @@ const Hints = Module("hints", {
|
||||
[0xfb00, 0xfb06, ["ff", "fi", "fl", "ffi", "ffl", "st", "st"]],
|
||||
[0xff21, 0xff3a, "A"], [0xff41, 0xff5a, "a"]
|
||||
].forEach(function (start, stop, val) {
|
||||
if (typeof a[2] != "string")
|
||||
for (i=start; i <= stop; i++)
|
||||
if (typeof val != "string")
|
||||
for (let i=start; i <= stop; i++)
|
||||
table[String.fromCharCode(i)] = val[(i - start) % val.length];
|
||||
else {
|
||||
let n = val.charCodeAt(0);
|
||||
for (i=start; i <= stop; i++)
|
||||
for (let i=start; i <= stop; i++)
|
||||
table[String.fromCharCode(i)] = String.fromCharCode(n + i - start);
|
||||
}
|
||||
});
|
||||
|
||||
delete this.translitTable;
|
||||
return this.translitTable = table;
|
||||
},
|
||||
return table;
|
||||
}),
|
||||
indexOf: function indexOf(dest, src) {
|
||||
let table = this.translitTable;
|
||||
var end = dest.length - src.length;
|
||||
|
||||
@@ -592,7 +592,7 @@ const JavaScript = Module("javascript", {
|
||||
* A list of properties of the global object which are not
|
||||
* enumerable by any standard method.
|
||||
*/
|
||||
globalNames: array.uniq([
|
||||
globalNames: Class.memoize(function () array.uniq([
|
||||
"Array", "ArrayBuffer", "AttributeName", "Boolean",
|
||||
"CSSFontFaceStyleDecl", "CSSGroupRuleRuleList", "CSSNameSpaceRule",
|
||||
"CSSRGBColor", "CSSRect", "ComputedCSSStyleDeclaration", "Date",
|
||||
@@ -610,7 +610,7 @@ const JavaScript = Module("javascript", {
|
||||
"undefined", "uneval"
|
||||
].concat([k.substr(6) for (k in keys(Ci)) if (/^nsIDOM/.test(k))])
|
||||
.concat([k.substr(3) for (k in keys(Ci)) if (/^nsI/.test(k))])
|
||||
.filter(function (k) k in window)),
|
||||
.filter(function (k) k in window))),
|
||||
|
||||
/**
|
||||
* Installs argument string completers for a set of functions.
|
||||
|
||||
@@ -129,6 +129,8 @@ const Modes = Module("modes", {
|
||||
|
||||
get mainMode() this._modeMap[this._main],
|
||||
|
||||
get topOfStack() this._modeStack[this._modeStack.length - 1],
|
||||
|
||||
addMode: function (name, extended, options) {
|
||||
let disp = name.replace("_", " ", "g");
|
||||
this[name] = 1 << this._lastMode++;
|
||||
@@ -179,12 +181,19 @@ const Modes = Module("modes", {
|
||||
this.show();
|
||||
},
|
||||
|
||||
save: function (id, value, obj, prop) {
|
||||
if (this.topOfStack)
|
||||
this.topOfStack[2][id] = { value: value, obj: obj, prop: prop };
|
||||
},
|
||||
|
||||
// helper function to set both modes in one go
|
||||
// if silent == true, you also need to take care of the mode handling changes yourself
|
||||
set: function (mainMode, extendedMode, silent, stack) {
|
||||
silent = (silent || this._main == mainMode && this._extended == extendedMode);
|
||||
// if a this._main mode is set, the this._extended is always cleared
|
||||
let oldMain = this._main, oldExtended = this._extended;
|
||||
if (!stack && mainMode != null)
|
||||
this.modeStack = [];
|
||||
if (typeof extendedMode === "number")
|
||||
this._extended = extendedMode;
|
||||
if (typeof mainMode === "number") {
|
||||
@@ -195,6 +204,8 @@ const Modes = Module("modes", {
|
||||
if (this._main != oldMain)
|
||||
this._handleModeChange(oldMain, mainMode, oldExtended);
|
||||
}
|
||||
if (mainMode != null && !(stack && stack.pop))
|
||||
this._modeStack.push([this._main, this._extended, {}]);
|
||||
dactyl.triggerObserver("modeChange", [oldMain, oldExtended], [this._main, this._extended], stack);
|
||||
|
||||
if (!silent)
|
||||
@@ -202,16 +213,18 @@ const Modes = Module("modes", {
|
||||
},
|
||||
|
||||
push: function (mainMode, extendedMode, silent) {
|
||||
this._modeStack.push([this._main, this._extended]);
|
||||
this.set(mainMode, extendedMode, silent, { push: this._modeStack[this._modeStack.length - 1] });
|
||||
this.set(mainMode, extendedMode, silent, { push: this.topOfStack });
|
||||
},
|
||||
|
||||
pop: function (silent) {
|
||||
let a = this._modeStack.pop();
|
||||
if (a)
|
||||
this.set(a[0], a[1], silent, { pop: a });
|
||||
else
|
||||
if (!this.topOfStack)
|
||||
this.reset(silent);
|
||||
else {
|
||||
this.set(this.topOfStack[0], this.topOfStack[1], silent, { pop: a });
|
||||
for (let [k, { obj, prop, value }] in Iterator(this.topOfStack[2]))
|
||||
obj[prop] = value;
|
||||
}
|
||||
},
|
||||
|
||||
// TODO: Deprecate this in favor of addMode? --Kris
|
||||
@@ -256,6 +269,7 @@ const Modes = Module("modes", {
|
||||
|
||||
get extended() this._extended,
|
||||
set extended(value) { this.set(null, value); }
|
||||
}, {
|
||||
});
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et:
|
||||
|
||||
Reference in New Issue
Block a user