def _incremental_search(self) -> None: """Run incremental search if enabled.""" if not search.use_incremental(self.mode): return with contextlib.suppress(IndexError): # Not enough text prefix, text = self._split_prefix(self.text()) if prefix in "/?" and text: search.search(text, self.mode, reverse=prefix == "?", incremental=True)
def _command_func(prefix, command, mode): """Return callable function for command depending on prefix.""" if prefix == ":": return lambda: runners.run(command, mode=mode) # No need to search again if incsearch is enabled if prefix in "/?" and not search.use_incremental(mode): return lambda: search.search(command, mode, reverse=prefix == "?") return lambda: None
def _on_return_pressed(self) -> None: """Run command and store history on return.""" prefix, command = self._split_prefix(self.text()) if not command: # Only prefix entered return self._history[self.mode].update(prefix + command) # Run commands in QTimer so the command line has been left when the # command runs if prefix == ":": QTimer.singleShot(0, lambda: runners.run(command, mode=self.mode)) elif not search.use_incremental(self.mode): QTimer.singleShot( 0, lambda: search.search( command, self.mode, reverse=prefix == "?"))
def run_search_reverse(text): search.search(text, api.modes.current(), reverse=True)
def run_search(text): search.search(text, api.modes.current())