Make it possible to go back/forward in a new tab.

This commit is contained in:
Florian Bruhin 2014-09-27 23:13:27 +02:00
parent 17f2241bc0
commit 8635dc8848
3 changed files with 22 additions and 12 deletions

View File

@ -270,12 +270,6 @@ Other
[n]gc
Clear tab n or of current tab, clears the history of the tab and loads about:blank. (command clear_tab, aliases: clear).
th
Go back in a new tab (command tab_hist_back, aliases: tabback, tba).
tl
Go forward in a new tab (command tab_hist_forward, aliases: tabforward, tfo).
c/
Find forward, ignore case (command find_forward_ic, alias: iffind).

View File

@ -299,25 +299,39 @@ class CommandDispatcher:
qtutils.deserialize(history, newtab.history())
return newtab
def _back_forward(self, tab, bg, count, forward):
"""Helper function for :back/:forward."""
if tab or bg:
widget = self.tab_clone(bg)
else:
widget = self._current_widget()
for _ in range(count):
if forward:
widget.go_forward()
else:
widget.go_back()
@cmdutils.register(instance='command-dispatcher')
def back(self, count=1):
def back(self, tab=False, bg=False, count=1):
"""Go back in the history of the current tab.
Args:
tab: Go back in a new tab.
bg: Go back in a background tab.
count: How many pages to go back.
"""
for _ in range(count):
self._current_widget().go_back()
self._back_forward(tab, bg, count, forward=False)
@cmdutils.register(instance='command-dispatcher')
def forward(self, count=1):
def forward(self, tab=False, bg=False, count=1):
"""Go forward in the history of the current tab.
Args:
tab: Go forward in a new tab.
bg: Go back in a background tab.
count: How many pages to go forward.
"""
for _ in range(count):
self._current_widget().go_forward()
self._back_forward(tab, bg, count, forward=True)
def _navigate_incdec(self, url, tab, incdec):
"""Helper method for :navigate when `where' is increment/decrement.

View File

@ -890,7 +890,9 @@ KEY_DATA = collections.OrderedDict([
('tab-clone', ['gC']),
('reload', ['r']),
('back', ['H', '<Backspace>']),
('back -t', ['th']),
('forward', ['L']),
('forward -t', ['tl']),
('hint', ['f']),
('hint all tab', ['F']),
('hint all tab-bg', [';b']),