From 8c80f99a32363ebc2b139e7c0074e4c165d992b3 Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Fri, 29 May 2015 21:18:44 +0200 Subject: [PATCH] Improve navigate option to scroll_page() --- qutebrowser/browser/commands.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 8c29ad317..735deba47 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -643,21 +643,27 @@ class CommandDispatcher: @cmdutils.register(instance='command-dispatcher', hide=True, scope='window', count='count') - def scroll_page(self, x: {'type': float}, y: {'type': float}, - navigate=None, count=1): + def scroll_page(self, x: {'type': float}, y: {'type': float}, *, + top_navigate: {'type': ('prev', 'decrement')}=None, + bottom_navigate: {'type': ('next', 'increment')}=None, + count=1): """Scroll the frame page-wise. Args: x: How many pages to scroll to the right. y: How many pages to scroll down. - navigate: :navigate to the next page on bottom + bottom_navigate: :navigate to the next page on bottom + top_navigate: :navigate to the previous page on top count: multiplier """ frame = self._current_widget().page().currentFrame() - if (navigate is not None and + if (bottom_navigate is not None and frame.scrollPosition().y() >= frame.scrollBarMaximum(Qt.Vertical)): - self.navigate(navigate) + self.navigate(bottom_navigate) + return + elif top_navigate is not None and frame.scrollPosition().y() == 0: + self.navigate(top_navigate) return mult_x = count * x