From b158cd78b591a7b78fa9bf92c68ca57b782528c6 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 30 Jan 2014 07:08:45 +0100 Subject: [PATCH] Allow non-None default for count --- qutebrowser/app.py | 2 +- qutebrowser/commands/utils.py | 4 +--- qutebrowser/widgets/browser.py | 20 +++++--------------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 6809da11a..b92fab3e4 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -193,7 +193,7 @@ class QuteBrowser(QApplication): handler = handlers[cmd] - if self.sender().count: + if count is not None and self.sender().count: return handler(*args, count=count) else: return handler(*args) diff --git a/qutebrowser/commands/utils.py b/qutebrowser/commands/utils.py index c5034fa3c..c99e6bf1f 100644 --- a/qutebrowser/commands/utils.py +++ b/qutebrowser/commands/utils.py @@ -61,10 +61,8 @@ class SearchParser(QObject): self.flags = QWebPage.FindBackward self.do_search.emit(self.text, self.flags) - def nextsearch(self, count=None): + def nextsearch(self, count=1): """Continue the search to the ([count]th) next term.""" - if count is None: - count = 1 if self.text is not None: for i in range(count): # pylint: disable=unused-variable self.do_search.emit(self.text, self.flags) diff --git a/qutebrowser/widgets/browser.py b/qutebrowser/widgets/browser.py index bdaec2ae8..a8f280982 100644 --- a/qutebrowser/widgets/browser.py +++ b/qutebrowser/widgets/browser.py @@ -139,27 +139,23 @@ class TabbedBrowser(TabWidget): preview.paintRequested.connect(tab.print) preview.exec_() - def cur_back(self, count=None): + def cur_back(self, count=1): """Go back in the history of the current tab. Go back for 1 page if count is unset, else go back [count] pages. Command handler for :back. """ # FIXME display warning if beginning of history - if count is None: - count = 1 for i in range(count): # pylint: disable=unused-variable self.currentWidget().back() - def cur_forward(self, count=None): + def cur_forward(self, count=1): """Go forward in the history of the current tab. Go forward for 1 page if count is unset, else go forward [count] pages. Command handler for :forward. """ # FIXME display warning if end of history - if count is None: - count = 1 for i in range(count): # pylint: disable=unused-variable self.currentWidget().forward() @@ -171,13 +167,11 @@ class TabbedBrowser(TabWidget): """ self.currentWidget().findText(text, flags) - def cur_scroll(self, dx, dy, count=None): + def cur_scroll(self, dx, dy, count=1): """Scroll the current tab by count * dx/dy Command handler for :scroll. """ - if count is None: - count = 1 dx = int(count) * int(dx) dy = int(count) * int(dy) self.currentWidget().page().mainFrame().scroll(dx, dy) @@ -212,13 +206,11 @@ class TabbedBrowser(TabWidget): return frame.setScrollBarValue(orientation, int(m * perc / 100)) - def switch_prev(self, count=None): + def switch_prev(self, count=1): """Switch to the ([count]th) previous tab. Command handler for :tabprev. """ - if count is None: - count = 1 idx = self.currentIndex() if idx - count >= 0: self.setCurrentIndex(idx - count) @@ -226,13 +218,11 @@ class TabbedBrowser(TabWidget): # FIXME pass - def switch_next(self, count=None): + def switch_next(self, count=1): """Switch to the ([count]th) next tab. Command handler for :tabnext. """ - if count is None: - count = 1 idx = self.currentIndex() if idx + count < self.count(): self.setCurrentIndex(idx + count)