1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 23:47:58 +01:00

Fix <A-Tab>

This commit is contained in:
Kris Maglione
2011-10-04 03:05:39 -04:00
parent 0c1fc4f421
commit 3693c79f13
4 changed files with 41 additions and 30 deletions

View File

@@ -1381,6 +1381,7 @@ var CommandLine = Module("commandline", {
if (this.context.waitingForTab || this.wildIndex == -1) if (this.context.waitingForTab || this.wildIndex == -1)
this.complete(true, true); this.complete(true, true);
this.wildtypes = wildmode;
let count = Math.abs(offset); let count = Math.abs(offset);
let steps = Math.constrain(this.wildtypes.length - this.wildIndex, let steps = Math.constrain(this.wildtypes.length - this.wildIndex,
1, count); 1, count);

View File

@@ -565,19 +565,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
}, },
focus: function focus(elem, flags) { focus: function focus(elem, flags) {
flags = flags || services.focus.FLAG_BYMOUSE; DOM(elem).focus(flags);
try {
if (elem instanceof Document)
elem = elem.defaultView;
if (elem instanceof Element)
services.focus.setFocus(elem, flags);
else if (elem instanceof Window)
services.focus.focusedWindow = elem;
}
catch (e) {
util.dump(elem);
util.reportError(e);
}
}, },
/** /**

View File

@@ -289,8 +289,6 @@ var Buffer = Module("Buffer", {
* @param {Node} elem The element to focus. * @param {Node} elem The element to focus.
*/ */
focusElement: function focusElement(elem) { focusElement: function focusElement(elem) {
let { Editor, dactyl } = this.modules;
let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem; let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem;
overlay.setData(elem, "focus-allowed", true); overlay.setData(elem, "focus-allowed", true);
overlay.setData(win.document, "focus-allowed", true); overlay.setData(win.document, "focus-allowed", true);
@@ -313,15 +311,17 @@ var Buffer = Module("Buffer", {
else else
flags = services.focus.FLAG_SHOWRING; flags = services.focus.FLAG_SHOWRING;
// Hack to deal with current versions of Firefox misplacing
// the caret
if (!overlay.getData(elem, "had-focus", false) && if (!overlay.getData(elem, "had-focus", false) &&
elem.value && elem.value &&
elem instanceof Ci.nsIDOMHTMLInputElement && elem instanceof Ci.nsIDOMHTMLInputElement &&
Editor.getEditor(elem) && DOM(elem).isEditable &&
elem.selectionStart != null && elem.selectionStart != null &&
elem.selectionStart == elem.selectionEnd) elem.selectionStart == elem.selectionEnd)
elem.selectionStart = elem.selectionEnd = elem.value.length; elem.selectionStart = elem.selectionEnd = elem.value.length;
dactyl.focus(elem, flags); DOM(elem).focus(flags);
if (elem instanceof Ci.nsIDOMWindow) { if (elem instanceof Ci.nsIDOMWindow) {
let sel = elem.getSelection(); let sel = elem.getSelection();
@@ -813,8 +813,6 @@ var Buffer = Module("Buffer", {
* count skips backwards. * count skips backwards.
*/ */
shiftFrameFocus: function shiftFrameFocus(count) { shiftFrameFocus: function shiftFrameFocus(count) {
let { dactyl } = this.modules;
if (!(this.doc instanceof Ci.nsIDOMHTMLDocument)) if (!(this.doc instanceof Ci.nsIDOMHTMLDocument))
return; return;
@@ -835,20 +833,21 @@ var Buffer = Module("Buffer", {
// calculate the next frame to focus // calculate the next frame to focus
let next = current + count; let next = current + count;
if (next < 0 || next >= frames.length) if (next < 0 || next >= frames.length)
util.dactyl.beep();
dactyl.beep(); dactyl.beep();
next = Math.constrain(next, 0, frames.length - 1); next = Math.constrain(next, 0, frames.length - 1);
// focus next frame and scroll into view // focus next frame and scroll into view
dactyl.focus(frames[next]); DOM(frames[next]).focus();
if (frames[next] != this.win) if (frames[next] != this.win)
DOM(frames[next].frameElement).scrollIntoView(); DOM(frames[next].frameElement).scrollIntoView();
// add the frame indicator // add the frame indicator
let doc = frames[next].document; let doc = frames[next].document;
let indicator = util.xmlToDom(<div highlight="FrameIndicator"/>, doc); let indicator = DOM(<div highlight="FrameIndicator"/>, doc)
(doc.body || doc.documentElement || doc).appendChild(indicator); .appendTo(doc.body || doc.documentElement || doc);
util.timeout(function () { doc.body.removeChild(indicator); }, 500); util.timeout(function () { indicator.remove(); }, 500);
// Doesn't unattach // Doesn't unattach
//doc.body.setAttributeNS(NS.uri, "activeframe", "true"); //doc.body.setAttributeNS(NS.uri, "activeframe", "true");

View File

@@ -358,9 +358,16 @@ var DOM = Class("DOM", {
scrollPos: function scrollPos(left, top) { scrollPos: function scrollPos(left, top) {
if (arguments.length == 0) { if (arguments.length == 0) {
if (this[0] instanceof Ci.nsIDOMElement) if (this[0] instanceof Ci.nsIDOMElement)
return { top: this[0].scrollTop, left: this[0].scrollLeft }; return { top: this[0].scrollTop, left: this[0].scrollLeft,
height: this[0].scrollHeight, width: this[0].scrollWidth,
innerHeight: this[0].clientHeight, innerWidth: this[0].innerWidth };
if (this[0] instanceof Ci.nsIDOMWindow) if (this[0] instanceof Ci.nsIDOMWindow)
return { top: this[0].scrollY, left: this[0].scrollX }; return { top: this[0].scrollY, left: this[0].scrollX,
height: this[0].scrollMaxY + this[0].innerHeight,
width: this[0].scrollMaxX + this[0].innerWidth,
innerHeight: this[0].innerHeight, innerWidth: this[0].innerWidth };
return null; return null;
} }
let func = callable(left) && left; let func = callable(left) && left;
@@ -818,7 +825,21 @@ var DOM = Class("DOM", {
focus: function focus(arg, extra) { focus: function focus(arg, extra) {
if (callable(arg)) if (callable(arg))
return this.listen("focus", arg, extra); return this.listen("focus", arg, extra);
services.focus.setFocus(this[0], extra || services.focus.FLAG_BYMOUSE);
let elem = this[0];
let flags = arg || services.focus.FLAG_BYMOUSE;
try {
if (elem instanceof Ci.nsIDOMDocument)
elem = elem.defaultView;
if (elem instanceof Ci.nsIDOMElement)
services.focus.setFocus(elem, flags);
else if (elem instanceof Ci.nsIDOMWindow)
services.focus.focusedWindow = elem;
}
catch (e) {
util.dump(elem);
util.reportError(e);
}
return this; return this;
}, },
blur: function blur(arg, extra) { blur: function blur(arg, extra) {
@@ -1556,7 +1577,9 @@ var DOM = Class("DOM", {
}); });
Object.keys(DOM.Event.types).forEach(function (event) { Object.keys(DOM.Event.types).forEach(function (event) {
DOM.prototype[event.replace(/-(.)/g, function (m, m1) m1.toUpperCase())] = let name = event.replace(/-(.)/g, function (m, m1) m1.toUpperCase());
if (!Set.has(DOM.prototype, name))
DOM.prototype[name] =
function _event(arg, extra) { function _event(arg, extra) {
return this[callable(arg) ? "listen" : "dispatch"](event, arg, extra); return this[callable(arg) ? "listen" : "dispatch"](event, arg, extra);
}; };