Add a :tab-detach command.

See #62.
This commit is contained in:
Florian Bruhin 2015-03-30 12:14:15 +02:00
parent 33dff70357
commit a38c3ae1e1
2 changed files with 15 additions and 1 deletions

View File

@ -45,6 +45,7 @@
|<<stop,stop>>|Stop loading in the current/[count]th tab.
|<<tab-clone,tab-clone>>|Duplicate the current tab.
|<<tab-close,tab-close>>|Close the current/[count]th tab.
|<<tab-detach,tab-detach>>|Detach the current tab to its own window.
|<<tab-focus,tab-focus>>|Select the tab given as argument/[count].
|<<tab-move,tab-move>>|Move the current tab.
|<<tab-next,tab-next>>|Switch to the next tab, or switch [count] tabs forward.
@ -508,6 +509,10 @@ Close the current/[count]th tab.
==== count
The tab index to close
[[tab-detach]]
=== tab-detach
Detach the current tab to its own window.
[[tab-focus]]
=== tab-focus
Syntax: +:tab-focus ['index']+

View File

@ -109,7 +109,7 @@ class CommandDispatcher:
raise cmdexc.CommandError("No WebView available yet!")
return widget
def _open(self, url, tab, background, window):
def _open(self, url, tab=False, background=False, window=False):
"""Helper function to open a page.
Args:
@ -404,6 +404,15 @@ class CommandDispatcher:
qtutils.deserialize(history, newtab.history())
return newtab
@cmdutils.register(instance='command-dispatcher', scope='window')
def tab_detach(self):
"""Detach the current tab to its own window."""
url = self._current_url()
self._open(url, window=True)
tabbed_browser = self._tabbed_browser()
cur_widget = self._current_widget()
tabbed_browser.close_tab(cur_widget)
def _back_forward(self, tab, bg, window, count, forward):
"""Helper function for :back/:forward."""
if (not forward and not