From 5fce707bb2d2ba72cea4f149e7861350afdf33a2 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 20 Jan 2014 17:01:52 +0100 Subject: [PATCH] Replace scroll{up,down,left,right} by scroll cmd --- qutebrowser/app.py | 5 +---- qutebrowser/commands/commands.py | 16 ++-------------- qutebrowser/widgets/browser.py | 28 ++++++---------------------- 3 files changed, 9 insertions(+), 40 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 5d4e0a698..a9bbbd3af 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -120,10 +120,7 @@ class QuteBrowser(QApplication): 'back': self.mainwindow.tabs.cur_back, 'forward': self.mainwindow.tabs.cur_forward, 'print': self.mainwindow.tabs.cur_print, - 'scrolldown': self.mainwindow.tabs.cur_scroll_down, - 'scrollup': self.mainwindow.tabs.cur_scroll_up, - 'scrollleft': self.mainwindow.tabs.cur_scroll_left, - 'scrollright': self.mainwindow.tabs.cur_scroll_right, + 'scroll': self.mainwindow.tabs.cur_scroll, 'scrollstart': self.mainwindow.tabs.cur_scroll_start, 'scrollend': self.mainwindow.tabs.cur_scroll_end, 'undo': self.mainwindow.tabs.undo_close, diff --git a/qutebrowser/commands/commands.py b/qutebrowser/commands/commands.py index daa26f69e..87e96683a 100644 --- a/qutebrowser/commands/commands.py +++ b/qutebrowser/commands/commands.py @@ -49,20 +49,8 @@ class Forward(Command): class Print(Command): nargs = 0 -class ScrollLeft(Command): - nargs = 0 - count = True - -class ScrollDown(Command): - nargs = 0 - count = True - -class ScrollUp(Command): - nargs = 0 - count = True - -class ScrollRight(Command): - nargs = 0 +class Scroll(Command): + nargs = 2 count = True class Undo(Command): diff --git a/qutebrowser/widgets/browser.py b/qutebrowser/widgets/browser.py index da3e68b2b..528fa78ff 100644 --- a/qutebrowser/widgets/browser.py +++ b/qutebrowser/widgets/browser.py @@ -84,29 +84,13 @@ class TabbedBrowser(TabWidget): # FIXME display warning if end of history self.currentWidget().forward() - def cur_scroll_down(self, count=None): - """Scrolls the current tab down""" + def cur_scroll(self, dx, dy, count=None): + """Scrolls the current tab by count * dx/dy""" if count is None: - count = 50 - self.currentWidget().page().mainFrame().scroll(0, count) - - def cur_scroll_up(self, count=None): - """Scrolls the current tab up""" - if count is None: - count = 50 - self.currentWidget().page().mainFrame().scroll(0, -count) - - def cur_scroll_left(self, count=None): - """Scrolls the current tab left""" - if count is None: - count = 50 - self.currentWidget().page().mainFrame().scroll(-count, 0) - - def cur_scroll_right(self, count=None): - """Scrolls the current tab right""" - if count is None: - count = 50 - self.currentWidget().page().mainFrame().scroll(count, 0) + count = 1 + dx = int(count) * int(dx) + dy = int(count) * int(dy) + self.currentWidget().page().mainFrame().scroll(dx, dy) def cur_scroll_start(self): """Scrolls the current tab to the beginning"""