Merge branch 'krobelus-search'
This commit is contained in:
commit
6d1ac5d2a2
@ -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
|
||||
|
@ -34,6 +34,7 @@
|
||||
|<<restart,restart>>|Restart qutebrowser while keeping existing tabs open.
|
||||
|<<run-userscript,run-userscript>>|Run an userscript given as argument.
|
||||
|<<save,save>>|Save the config file.
|
||||
|<<search,search>>|Search for a text on the current page.
|
||||
|<<set,set>>|Set an option.
|
||||
|<<set-cmd-text,set-cmd-text>>|Preset the statusbar to some text.
|
||||
|<<spawn,spawn>>|Spawn a command in a shell.
|
||||
@ -364,6 +365,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']+
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user