Feature - incremental_search
Added config option to find on a page incrementally, renewing the search each time a new character is entered.
This commit is contained in:
parent
22434f4d1b
commit
c1094b6660
@ -43,6 +43,11 @@ ignore_case:
|
||||
default: smart
|
||||
desc: When to find text on a page case-insensitively.
|
||||
|
||||
incremental_search:
|
||||
type: Bool
|
||||
default: False
|
||||
desc: Find text on a page incrementally, renewing the search for each typing character.
|
||||
|
||||
new_instance_open_target:
|
||||
type:
|
||||
name: String
|
||||
|
@ -26,7 +26,8 @@ from qutebrowser.keyinput import modeman, modeparsers
|
||||
from qutebrowser.commands import cmdexc, cmdutils
|
||||
from qutebrowser.misc import cmdhistory, editor
|
||||
from qutebrowser.misc import miscwidgets as misc
|
||||
from qutebrowser.utils import usertypes, log, objreg, message
|
||||
from qutebrowser.utils import usertypes, log, objreg
|
||||
from qutebrowser.config import config
|
||||
|
||||
|
||||
class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
||||
@ -45,6 +46,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
||||
update_completion: Emitted when the completion should be shown/updated.
|
||||
show_cmd: Emitted when command input should be shown.
|
||||
hide_cmd: Emitted when command input can be hidden.
|
||||
update_search: Emitted when search term could be updated.
|
||||
"""
|
||||
|
||||
got_cmd = pyqtSignal([str], [str, int])
|
||||
@ -53,6 +55,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
||||
update_completion = pyqtSignal()
|
||||
show_cmd = pyqtSignal()
|
||||
hide_cmd = pyqtSignal()
|
||||
update_search = pyqtSignal()
|
||||
|
||||
def __init__(self, *, win_id, private, parent=None):
|
||||
misc.CommandLineEdit.__init__(self, parent=parent)
|
||||
@ -66,6 +69,8 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
||||
self.cursorPositionChanged.connect(self.update_completion)
|
||||
self.textChanged.connect(self.update_completion)
|
||||
self.textChanged.connect(self.updateGeometry)
|
||||
self.textChanged.connect(self.update_search)
|
||||
self.update_search.connect(self.incrementSearch)
|
||||
|
||||
def prefix(self):
|
||||
"""Get the currently entered command prefix."""
|
||||
@ -238,3 +243,13 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
||||
text = 'x'
|
||||
width = self.fontMetrics().width(text)
|
||||
return QSize(width, height)
|
||||
|
||||
def incrementSearch(self):
|
||||
if config.val.incremental_search == True:
|
||||
search_prefixes = {
|
||||
'/': 'search -- ',
|
||||
'?': 'search -r -- ',
|
||||
}
|
||||
if self.prefix() == '/' or self.prefix() == '?':
|
||||
text = self.text()
|
||||
self.got_cmd[str].emit(search_prefixes[text[0]] + text[1:])
|
||||
|
Loading…
Reference in New Issue
Block a user