mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-03 11:24:12 +01:00
Remember last focused frame
This commit is contained in:
@@ -92,9 +92,9 @@ function Buffer() //{{{
|
||||
if (win.scrollMaxX > 0 || win.scrollMaxY > 0)
|
||||
return win;
|
||||
|
||||
for (let i = 0; i < win.frames.length; i++)
|
||||
if (win.frames[i].scrollMaxX > 0 || win.frames[i].scrollMaxY > 0)
|
||||
return win.frames[i];
|
||||
for (let frame in util.Array.iterator(win.frames))
|
||||
if (frame.scrollMaxX > 0 || frame.scrollMaxY > 0)
|
||||
return frame;
|
||||
|
||||
return win;
|
||||
}
|
||||
@@ -1184,6 +1184,7 @@ function Buffer() //{{{
|
||||
if (!window.content.document instanceof HTMLDocument)
|
||||
return;
|
||||
|
||||
count = Math.max(count, 1);
|
||||
var frames = [];
|
||||
|
||||
// find all frames - depth-first search
|
||||
@@ -1216,32 +1217,24 @@ function Buffer() //{{{
|
||||
var next = current;
|
||||
if (forward)
|
||||
{
|
||||
if (count > 1)
|
||||
next = current + count;
|
||||
else
|
||||
next++;
|
||||
|
||||
if (next > frames.length - 1)
|
||||
{
|
||||
if (current == frames.length - 1)
|
||||
liberator.beep(); // still allow the frame indicator to be activated
|
||||
|
||||
next = frames.length - 1;
|
||||
liberator.beep();
|
||||
next = frames.length - 1; // still allow the frame indicator to be activated
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (count > 1)
|
||||
next = current - count;
|
||||
else
|
||||
next--;
|
||||
|
||||
if (next < 0)
|
||||
{
|
||||
if (current == 0)
|
||||
liberator.beep(); // still allow the frame indicator to be activated
|
||||
|
||||
next = 0;
|
||||
liberator.beep();
|
||||
next = 0; // still allow the frame indicator to be activated
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1263,7 +1256,7 @@ function Buffer() //{{{
|
||||
// TODO: print more useful information, just like the DOM inspector
|
||||
showElementInfo: function (elem)
|
||||
{
|
||||
liberator.echo(<>Element:<br/></> + util.objectToString(elem), commandline.FORCE_MULTILINE);
|
||||
liberator.echo(<>Element:<br/>{util.objectToString(elem, true)}</>, commandline.FORCE_MULTILINE);
|
||||
},
|
||||
|
||||
showPageInfo: function (verbose)
|
||||
|
||||
@@ -1064,6 +1064,9 @@ function Events() //{{{
|
||||
var win = window.document.commandDispatcher.focusedWindow;
|
||||
var elem = window.document.commandDispatcher.focusedElement;
|
||||
|
||||
if (win && win.top == content && liberator.has("tabs"))
|
||||
tabs.localStore.focusedFrame = win;
|
||||
|
||||
if (elem && elem.readOnly)
|
||||
return;
|
||||
|
||||
|
||||
@@ -820,7 +820,7 @@ const liberator = (function () //{{{
|
||||
// if clearFocusedElement, also blur a focused link
|
||||
focusContent: function (clearFocusedElement)
|
||||
{
|
||||
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
||||
let ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
||||
.getService(Components.interfaces.nsIWindowWatcher);
|
||||
if (window == ww.activeWindow && document.commandDispatcher.focusedElement && clearFocusedElement)
|
||||
document.commandDispatcher.focusedElement.blur();
|
||||
@@ -830,16 +830,21 @@ const liberator = (function () //{{{
|
||||
{
|
||||
if (liberator.has("mail") && clearFocusedElement && !config.isComposeWindow)
|
||||
{
|
||||
var i = gDBView.selection.currentIndex;
|
||||
let i = gDBView.selection.currentIndex;
|
||||
if (i == -1 && gDBView.rowCount >= 0)
|
||||
i = 0;
|
||||
|
||||
gDBView.selection.select(i);
|
||||
}
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
var elem = config.mainWidget || window.content;
|
||||
let elem = config.mainWidget || window.content;
|
||||
if (this.has("tabs"))
|
||||
{
|
||||
let frame = tabs.localStore.focusedFrame;
|
||||
if (frame && frame.top == window.content)
|
||||
elem = frame;
|
||||
}
|
||||
if (elem && (elem != document.commandDispatcher.focusedElement))
|
||||
elem.focus();
|
||||
},
|
||||
|
||||
@@ -674,14 +674,20 @@ function Tabs() //{{{
|
||||
|
||||
get count() getBrowser().mTabs.length,
|
||||
|
||||
// used for :setlocal
|
||||
get options()
|
||||
{
|
||||
var tab = this.getTab();
|
||||
if (!tab.liberatorOptions)
|
||||
tab.liberatorOptions = {};
|
||||
let store = this.localStore;
|
||||
if (!("options" in store))
|
||||
store.options = {};
|
||||
return store.options;
|
||||
},
|
||||
|
||||
return tab.liberatorOptions;
|
||||
get localStore()
|
||||
{
|
||||
let tab = this.getTab();
|
||||
if (!tab.liberatorStore)
|
||||
tab.liberatorStore = {};
|
||||
return tab.liberatorStore;
|
||||
},
|
||||
|
||||
get tabStrip()
|
||||
@@ -696,15 +702,7 @@ function Tabs() //{{{
|
||||
index: function (tab)
|
||||
{
|
||||
if (tab)
|
||||
{
|
||||
var length = getBrowser().mTabs.length;
|
||||
for (let i = 0; i < length; i++)
|
||||
{
|
||||
if (getBrowser().mTabs[i] == tab)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return Array.indexOf(getBrowser().mTabs, tab);
|
||||
|
||||
return getBrowser().mTabContainer.selectedIndex;
|
||||
},
|
||||
@@ -737,7 +735,7 @@ function Tabs() //{{{
|
||||
|
||||
getTab: function (index)
|
||||
{
|
||||
if (index)
|
||||
if (index != undefined)
|
||||
return getBrowser().mTabs[index];
|
||||
|
||||
return getBrowser().mTabContainer.selectedItem;
|
||||
|
||||
Reference in New Issue
Block a user