mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 11:58:00 +01:00
Adding :tabduplicate patch from Konstantin Stepanov
This commit is contained in:
@@ -426,6 +426,23 @@ liberator.Tabs = function () //{{{
|
||||
liberator.open("about:blank", where);
|
||||
},
|
||||
{ completer: function (filter) { return liberator.completion.url(filter); } });
|
||||
|
||||
liberator.commands.add(["tabd[uplicate]"],
|
||||
"Duplicate current tab",
|
||||
function (args, special, count)
|
||||
{
|
||||
var tab = liberator.tabs.getTab();
|
||||
|
||||
var activate = special ? true : false;
|
||||
if (/\btabopen\b/.test(liberator.options["activate"]))
|
||||
activate = !activate;
|
||||
|
||||
if (count < 1)
|
||||
count = 1;
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
liberator.tabs.cloneTab(tab, activate);
|
||||
});
|
||||
}
|
||||
|
||||
if (liberator.has("session"))
|
||||
@@ -795,6 +812,23 @@ liberator.Tabs = function () //{{{
|
||||
}
|
||||
},
|
||||
|
||||
cloneTab: function (tab, activate)
|
||||
{
|
||||
var ss = Components.classes["@mozilla.org/browser/sessionstore;1"].
|
||||
getService(Components.interfaces.nsISessionStore);
|
||||
|
||||
if (!tab)
|
||||
tab = getBrowser().mTabContainer.selectedItem;
|
||||
|
||||
var tabState = ss.getTabState(tab);
|
||||
var newTab = getBrowser().addTab();
|
||||
ss.setTabState(newTab, tabState);
|
||||
if (activate)
|
||||
getBrowser().mTabContainer.selectedItem = newTab;
|
||||
|
||||
return newTab;
|
||||
},
|
||||
|
||||
// TODO: when restarting a session FF selects the first tab and then the
|
||||
// tab that was selected when the session was created. As a result the
|
||||
// alternate after a restart is often incorrectly tab 1 when there
|
||||
|
||||
Reference in New Issue
Block a user