Merge prev-page/next-page into a navigate command.

This commit is contained in:
Florian Bruhin 2014-09-22 20:57:50 +02:00
parent 42826a2214
commit 51413094bf
2 changed files with 17 additions and 21 deletions

View File

@ -308,28 +308,24 @@ class CommandDispatcher:
self._current_widget().hintmanager.follow_hint() self._current_widget().hintmanager.follow_hint()
@cmdutils.register(instance='mainwindow.tabs.cmd') @cmdutils.register(instance='mainwindow.tabs.cmd')
def prev_page(self, tab=False): def navigate(self, where : ('prev', 'next'), tab=False):
"""Open a "previous" link. """Open typical prev/next links.
This tries to automatically click on typical _Previous Page_ links This tries to automatically click on typical _Previous Page_ or
using some heuristics. _Next Page_ links using some heuristics.
Args: Args:
where: What to open.
- `prev`: Open a _previous_ link.
- `next`: Open a _next_ link.
tab: Open in a new tab. tab: Open in a new tab.
""" """
self._prevnext(prev=True, newtab=tab) if where == 'prev':
self._prevnext(prev=True, newtab=tab)
@cmdutils.register(instance='mainwindow.tabs.cmd') elif where == 'next':
def next_page(self, tab=False): self._prevnext(prev=False, newtab=tab)
"""Open a "next" link.
This tries to automatically click on typical _Next Page_ links using
some heuristics.
Args:
tab: Open in a new tab.
"""
self._prevnext(prev=False, newtab=tab)
@cmdutils.register(instance='mainwindow.tabs.cmd', hide=True) @cmdutils.register(instance='mainwindow.tabs.cmd', hide=True)
def scroll(self, dx: float, dy: float, count=1): def scroll(self, dx: float, dy: float, count=1):

View File

@ -927,10 +927,10 @@ KEY_DATA = collections.OrderedDict([
('zoom-out', ['-']), ('zoom-out', ['-']),
('zoom-in', ['+']), ('zoom-in', ['+']),
('zoom', ['=']), ('zoom', ['=']),
('prev-page', ['[[']), ('navigate prev', ['[[']),
('next-page', [']]']), ('navigate next', [']]']),
('prev-page -t', ['{{']), ('navigate prev -t', ['{{']),
('next-page -t', ['}}']), ('navigate next -t', ['}}']),
('inspector', ['wi']), ('inspector', ['wi']),
('download-page', ['gd']), ('download-page', ['gd']),
('cancel-download', ['ad']), ('cancel-download', ['ad']),