From 8b69f9b62cc9cbcd2386d426e0ebc1d7afd48eec Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 29 Dec 2014 22:45:26 +0100 Subject: [PATCH 1/2] Registered 'search' as command. Fixes #421. --- doc/help/commands.asciidoc | 13 +++++++++++++ qutebrowser/commands/runners.py | 19 ++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index a1c5e9e45..b08c52ab3 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -33,6 +33,7 @@ |<>|Restart qutebrowser while keeping existing tabs open. |<>|Run an userscript given as argument. |<>|Save the config file. +|<>|Search for a text on the current page. |<>|Set an option. |<>|Preset the statusbar to some text. |<>|Spawn a command in a shell. @@ -354,6 +355,18 @@ Run an userscript given as argument. === save Save the config file. +[[search]] +=== search +Syntax: +:search [*--reverse*] 'text'+ + +Search for a text on the current page. + +==== positional arguments +* +'text'+: The text to search for. + +==== optional arguments +* +*-r*+, +*--reverse*+: Reverse search direction. + [[set]] === set Syntax: +:set [*--temp*] ['section'] ['option'] ['value']+ diff --git a/qutebrowser/commands/runners.py b/qutebrowser/commands/runners.py index 2fa07cb12..466c4c206 100644 --- a/qutebrowser/commands/runners.py +++ b/qutebrowser/commands/runners.py @@ -71,12 +71,14 @@ class SearchRunner(QObject): def __repr__(self): return utils.get_repr(self, text=self._text, flags=self._flags) - def _search(self, text, rev=False): + @pyqtSlot(str) + @cmdutils.register(instance='search-runner', scope='window', maxsplit=0) + def search(self, text, reverse=False): """Search for a text on the current page. Args: text: The text to search for. - rev: Search direction, True if reverse, else False. + reverse: Reverse search direction. """ if self._text is not None and self._text != text: # We first clear the marked text, then the highlights @@ -92,7 +94,7 @@ class SearchRunner(QObject): self._flags |= QWebPage.FindCaseSensitively if config.get('general', 'wrap-search'): self._flags |= QWebPage.FindWrapsAroundDocument - if rev: + if reverse: self._flags |= QWebPage.FindBackward # We actually search *twice* - once to highlight everything, then again # to get a mark so we can navigate. @@ -100,15 +102,6 @@ class SearchRunner(QObject): self.do_search.emit(self._text, self._flags | QWebPage.HighlightAllOccurrences) - @pyqtSlot(str) - def search(self, text): - """Search for a text on a website. - - Args: - text: The text to search for. - """ - self._search(text) - @pyqtSlot(str) def search_rev(self, text): """Search for a text on a website in reverse direction. @@ -116,7 +109,7 @@ class SearchRunner(QObject): Args: text: The text to search for. """ - self._search(text, rev=True) + self.search(text, reverse=True) @cmdutils.register(instance='search-runner', hide=True, scope='window') def search_next(self, count: {'special': 'count'}=1): From b0afe72e425dd6ca41e894198a353ae3b9451d32 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 1 Jan 2015 19:15:16 +0100 Subject: [PATCH 2/2] Regenerate authors --- README.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index 7e9028104..b647a1e65 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -131,9 +131,9 @@ Contributors, sorted by the number of commits in descending order: * Martin Zimmermann * Joel Torstensson * Brian Jackson +* Johannes Altmanninger * Mathias Fussenegger * Larry Hynes -* Johannes Altmanninger * Regina Hug * Peter Vilim * Helen Sherwood-Taylor