1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 08:07:59 +01:00

Replace tabs.localStore.focusedFrame with buffer.focusedFrame.

This commit is contained in:
Kris Maglione
2010-10-03 14:13:24 -04:00
parent 72b6af3e6b
commit c577b15ea6
5 changed files with 15 additions and 9 deletions

View File

@@ -344,8 +344,6 @@ const Buffer = Module("buffer", {
return content.dactylStore; return content.dactylStore;
}, },
/** /**
* @property {Node} The last focused input field in the buffer. Used * @property {Node} The last focused input field in the buffer. Used
* by the "gi" key binding. * by the "gi" key binding.
@@ -439,6 +437,14 @@ const Buffer = Module("buffer", {
return frames; return frames;
}, },
/**
* @property {Window} Returns the currently focused frame.
*/
get focusedFrame()
(dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame,
set focusedFrame(frame)
(dactyl.has("tabs") ? tabs.localStore : this.localStore).focusedFrame = frame,
/** /**
* Returns the currently selected word. If the selection is * Returns the currently selected word. If the selection is
* null, it tries to guess the word that the caret is * null, it tries to guess the word that the caret is
@@ -451,7 +457,7 @@ const Buffer = Module("buffer", {
// FIXME: getSelection() doesn't always preserve line endings, see: // FIXME: getSelection() doesn't always preserve line endings, see:
// https://www.mozdev.org/bugs/show_bug.cgi?id=19303 // https://www.mozdev.org/bugs/show_bug.cgi?id=19303
getCurrentWord: function () { getCurrentWord: function () {
let win = tabs.localStore.focusedFrame || content; let win = buffer.focusedFrame || content;
let selection = win.getSelection(); let selection = win.getSelection();
if (selection.rangeCount == 0) if (selection.rangeCount == 0)
return ""; return "";
@@ -932,7 +938,7 @@ const Buffer = Module("buffer", {
* @param {boolean} useExternalEditor View the source in the external editor. * @param {boolean} useExternalEditor View the source in the external editor.
*/ */
viewSource: function (url, useExternalEditor) { viewSource: function (url, useExternalEditor) {
let doc = tabs.localStore.focusedFrame.document; let doc = buffer.focusedFrame.document;
if (useExternalEditor) if (useExternalEditor)
this.viewSourceExternally(url || doc); this.viewSourceExternally(url || doc);
@@ -1219,7 +1225,7 @@ const Buffer = Module("buffer", {
commands.add(["frameo[nly]"], commands.add(["frameo[nly]"],
"Show only the current frame's page", "Show only the current frame's page",
function (args) { function (args) {
dactyl.open(tabs.localStore.focusedFrame.document.documentURI); dactyl.open(buffer.focusedFrame.document.documentURI);
}, },
{ argCount: "0" }); { argCount: "0" });

View File

@@ -388,7 +388,7 @@ const Dactyl = Module("dactyl", {
gDBView.selection.select(i); gDBView.selection.select(i);
} }
else if (this.has("tabs")) { else if (this.has("tabs")) {
let frame = tabs.localStore.focusedFrame; let frame = buffer.focusedFrame;
if (frame && frame.top == window.content) if (frame && frame.top == window.content)
elem = frame; elem = frame;
} }

View File

@@ -427,7 +427,7 @@ const Editor = Module("editor", {
let sel = controller.getSelection(controller.SELECTION_NORMAL); let sel = controller.getSelection(controller.SELECTION_NORMAL);
if (!sel.rangeCount) // Hack. if (!sel.rangeCount) // Hack.
sel.addRange(RangeFind.endpoint( sel.addRange(RangeFind.endpoint(
RangeFind.nodeRange(tabs.localStore.focusedFrame.document.documentElement), RangeFind.nodeRange(buffer.focusedFrame.document.documentElement),
true)); true));
while (count--) while (count--)
controller[caretModeMethod](caretModeArg, false); controller[caretModeMethod](caretModeArg, false);

View File

@@ -732,7 +732,7 @@ const Events = Module("events", {
let elem = window.document.commandDispatcher.focusedElement; let elem = window.document.commandDispatcher.focusedElement;
if (win && win.top == content && dactyl.has("tabs")) if (win && win.top == content && dactyl.has("tabs"))
tabs.localStore.focusedFrame = win; buffer.focusedFrame = win;
try { try {
if (elem && elem.readOnly) if (elem && elem.readOnly)

View File

@@ -302,7 +302,7 @@ const RangeFind = Class("RangeFind", {
get searchString() this.lastString, get searchString() this.lastString,
get selectedRange() { get selectedRange() {
let selection = (tabs.localStore.focusedFrame || content).getSelection(); let selection = (buffer.focusedFrame || content).getSelection();
return (selection.rangeCount ? selection.getRangeAt(0) : this.ranges[0].range).cloneRange(); return (selection.rangeCount ? selection.getRangeAt(0) : this.ranges[0].range).cloneRange();
}, },
set selectedRange(range) { set selectedRange(range) {