diff --git a/AUTHORS b/AUTHORS index f5e2884d..c8142cb0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -12,7 +12,7 @@ Inactive/former developers: * Viktor Kojouharov (Виктор Кожухаров) Patches (in no special order): - * Konstantin Stepanov (:%foo support) + * Konstantin Stepanov (:%foo support, :tabduplicate) * Lukas Mai * Guido Van Hoecke * Daniel Trstenjak (various things with hints) diff --git a/NEWS b/NEWS index fce21f2b..a4dd0389 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ generous donation which made this behavior possible) * IMPORTANT: ctrl-x/a never take possible negative URLs into account, it was just too unpredictable + * add :tabduplicate command * new 'urlseparator' option for specifying the regexp used to split the arg to :open, :tabopen and :winopen * :set editor now accepts quoting/escaping to use an editor with spaces in the path diff --git a/content/tabs.js b/content/tabs.js index 9a8b80a6..adcf1ccc 100644 --- a/content/tabs.js +++ b/content/tabs.js @@ -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 diff --git a/locale/en-US/browsing.txt b/locale/en-US/browsing.txt index 13b644e7..0807feb7 100644 --- a/locale/en-US/browsing.txt +++ b/locale/en-US/browsing.txt @@ -71,6 +71,13 @@ in a new tab. When used with [a]![a], the 'tabopen' value of the 'activate' opti ________________________________________________________________________________ +|:tabd| |:tabduplicate| +||:[count]tabd[uplicate][!]|| + +________________________________________________________________________________ +Duplicates current tab [count] times. Uses 'tabopen' value of the 'activate' to determine +if last cloned tab should be activated. When used with [a]![a], 'tabopen' value is negated. +________________________________________________________________________________ + |:winopen| |:wopen| |:winedit| ||:wino[pen][!] [arg1], [arg2], ...|| +