Add a :tab-clone command.

This commit is contained in:
Florian Bruhin 2014-09-27 23:13:11 +02:00
parent 4410536f69
commit 17f2241bc0
2 changed files with 18 additions and 0 deletions

View File

@ -282,6 +282,23 @@ class CommandDispatcher:
diag.setAttribute(Qt.WA_DeleteOnClose)
diag.open(lambda: tab.print(diag.printer()))
@cmdutils.register(instance='command-dispatcher')
def tab_clone(self, bg=False):
"""Duplicate the current tab.
Args:
bg: Open in a background tab.
Return:
The new QWebView.
"""
curtab = self._current_widget()
tabbed_browser = objreg.get('tabbed-browser')
newtab = tabbed_browser.tabopen(background=bg, explicit=True)
history = qtutils.serialize(curtab.history())
qtutils.deserialize(history, newtab.history())
return newtab
@cmdutils.register(instance='command-dispatcher')
def back(self, count=1):
"""Go back in the history of the current tab.

View File

@ -887,6 +887,7 @@ KEY_DATA = collections.OrderedDict([
('tab-move +', ['gr']),
('tab-next', ['J']),
('tab-prev', ['K']),
('tab-clone', ['gC']),
('reload', ['r']),
('back', ['H', '<Backspace>']),
('forward', ['L']),