Rename {Command,Search}Manager to ...Runner
This commit is contained in:
parent
eae81fa560
commit
aebce80b2b
@ -56,7 +56,7 @@ from qutebrowser.widgets.crash import (ExceptionCrashDialog, FatalCrashDialog,
|
||||
from qutebrowser.keyinput.modeparsers import (NormalKeyParser, HintKeyParser,
|
||||
PromptKeyParser)
|
||||
from qutebrowser.keyinput.keyparser import PassthroughKeyParser
|
||||
from qutebrowser.commands.managers import CommandManager, SearchManager
|
||||
from qutebrowser.commands.managers import CommandRunner, SearchRunner
|
||||
from qutebrowser.config.iniparsers import ReadWriteConfigParser
|
||||
from qutebrowser.config.lineparser import LineConfigParser
|
||||
from qutebrowser.browser.cookies import CookieJar
|
||||
@ -73,8 +73,8 @@ class Application(QApplication):
|
||||
|
||||
Attributes:
|
||||
mainwindow: The MainWindow QWidget.
|
||||
commandmanager: The main CommandManager instance.
|
||||
searchmanager: The main SearchManager instance.
|
||||
commandrunner: The main CommandRunner instance.
|
||||
searchrunner: The main SearchRunner instance.
|
||||
config: The main ConfigManager
|
||||
stateconfig: The "state" ReadWriteConfigParser instance.
|
||||
cmd_history: The "cmd_history" LineConfigParser instance.
|
||||
@ -147,9 +147,9 @@ class Application(QApplication):
|
||||
log.init.debug("Initializing cookies...")
|
||||
self.cookiejar = CookieJar(self)
|
||||
log.init.debug("Initializing commands...")
|
||||
self.commandmanager = CommandManager()
|
||||
self.commandrunner = CommandRunner()
|
||||
log.init.debug("Initializing search...")
|
||||
self.searchmanager = SearchManager(self)
|
||||
self.searchrunner = SearchRunner(self)
|
||||
log.init.debug("Initializing downloads...")
|
||||
self.downloadmanager = DownloadManager(self)
|
||||
log.init.debug("Initializing main window...")
|
||||
@ -327,7 +327,7 @@ class Application(QApplication):
|
||||
for cmd in self.args.command:
|
||||
if cmd.startswith(':'):
|
||||
log.init.debug("Startup cmd {}".format(cmd))
|
||||
self.commandmanager.run_safely_init(cmd.lstrip(':'))
|
||||
self.commandrunner.run_safely_init(cmd.lstrip(':'))
|
||||
else:
|
||||
log.init.debug("Startup URL {}".format(cmd))
|
||||
try:
|
||||
@ -384,13 +384,13 @@ class Application(QApplication):
|
||||
self.modeman.left.connect(status.prompt.prompter.on_mode_left)
|
||||
|
||||
# commands
|
||||
cmd.got_cmd.connect(self.commandmanager.run_safely)
|
||||
cmd.got_search.connect(self.searchmanager.search)
|
||||
cmd.got_search_rev.connect(self.searchmanager.search_rev)
|
||||
cmd.got_cmd.connect(self.commandrunner.run_safely)
|
||||
cmd.got_search.connect(self.searchrunner.search)
|
||||
cmd.got_search_rev.connect(self.searchrunner.search_rev)
|
||||
cmd.returnPressed.connect(tabs.setFocus)
|
||||
self.searchmanager.do_search.connect(tabs.search)
|
||||
self.searchrunner.do_search.connect(tabs.search)
|
||||
kp[KeyMode.normal].keystring_updated.connect(status.keystring.setText)
|
||||
tabs.got_cmd.connect(self.commandmanager.run_safely)
|
||||
tabs.got_cmd.connect(self.commandrunner.run_safely)
|
||||
|
||||
# hints
|
||||
kp[KeyMode.hint].fire_hint.connect(tabs.fire_hint)
|
||||
|
@ -17,7 +17,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""Module containing command managers (SearchManager and CommandManager)."""
|
||||
"""Module containing command managers (SearchRunner and CommandRunner)."""
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject
|
||||
from PyQt5.QtWebKitWidgets import QWebPage
|
||||
@ -31,9 +31,9 @@ from qutebrowser.utils.misc import safe_shlex_split
|
||||
from qutebrowser.utils.log import commands as logger
|
||||
|
||||
|
||||
class SearchManager(QObject):
|
||||
class SearchRunner(QObject):
|
||||
|
||||
"""Manage qutebrowser searches.
|
||||
"""Run searches on webpages.
|
||||
|
||||
Attributes:
|
||||
_text: The text from the last search.
|
||||
@ -101,7 +101,7 @@ class SearchManager(QObject):
|
||||
"""
|
||||
self._search(text, rev=True)
|
||||
|
||||
@cmdutils.register(instance='searchmanager', hide=True)
|
||||
@cmdutils.register(instance='searchrunner', hide=True)
|
||||
def search_next(self, count=1):
|
||||
"""Continue the search to the ([count]th) next term.
|
||||
|
||||
@ -115,7 +115,7 @@ class SearchManager(QObject):
|
||||
for _ in range(count):
|
||||
self.do_search.emit(self._text, self._flags)
|
||||
|
||||
@cmdutils.register(instance='searchmanager', hide=True)
|
||||
@cmdutils.register(instance='searchrunner', hide=True)
|
||||
def search_prev(self, count=1):
|
||||
"""Continue the search to the ([count]th) previous term.
|
||||
|
||||
@ -139,9 +139,9 @@ class SearchManager(QObject):
|
||||
self.do_search.emit(self._text, flags)
|
||||
|
||||
|
||||
class CommandManager:
|
||||
class CommandRunner:
|
||||
|
||||
"""Manage qutebrowser commandline commands.
|
||||
"""Parse and run qutebrowser commandline commands.
|
||||
|
||||
Attributes:
|
||||
_cmd: The command which was parsed.
|
||||
|
@ -36,11 +36,11 @@ import qutebrowser.utils.message as message
|
||||
from qutebrowser.utils.misc import get_standard_dir
|
||||
from qutebrowser.utils.log import procs as logger
|
||||
from qutebrowser.commands.exceptions import CommandError
|
||||
from qutebrowser.commands.managers import CommandManager
|
||||
from qutebrowser.commands.managers import CommandRunner
|
||||
|
||||
|
||||
_runners = []
|
||||
_commandmanager = None
|
||||
_commandrunner = None
|
||||
|
||||
|
||||
class _BlockingFIFOReader(QObject):
|
||||
@ -326,9 +326,9 @@ else:
|
||||
|
||||
|
||||
def init():
|
||||
"""Initialize the global _commandmanager."""
|
||||
global _commandmanager
|
||||
_commandmanager = CommandManager()
|
||||
"""Initialize the global _commandrunner."""
|
||||
global _commandrunner
|
||||
_commandrunner = CommandRunner()
|
||||
|
||||
|
||||
def run(cmd, *args, url):
|
||||
@ -337,7 +337,7 @@ def run(cmd, *args, url):
|
||||
# pass via env variable..
|
||||
urlstr = url.toString(QUrl.FullyEncoded)
|
||||
runner = UserscriptRunner()
|
||||
runner.got_cmd.connect(_commandmanager.run_safely)
|
||||
runner.got_cmd.connect(_commandrunner.run_safely)
|
||||
runner.run(cmd, *args, env={'QUTE_URL': urlstr})
|
||||
_runners.append(runner)
|
||||
runner.finished.connect(partial(_runners.remove, runner))
|
||||
|
@ -22,7 +22,7 @@
|
||||
from qutebrowser.keyinput.basekeyparser import BaseKeyParser
|
||||
import qutebrowser.utils.message as message
|
||||
|
||||
from qutebrowser.commands.managers import CommandManager
|
||||
from qutebrowser.commands.managers import CommandRunner
|
||||
from qutebrowser.commands.exceptions import CommandMetaError, CommandError
|
||||
|
||||
|
||||
@ -31,17 +31,17 @@ class CommandKeyParser(BaseKeyParser):
|
||||
"""KeyChainParser for command bindings.
|
||||
|
||||
Attributes:
|
||||
commandmanager: CommandManager instance.
|
||||
commandrunner: CommandRunner instance.
|
||||
"""
|
||||
|
||||
def __init__(self, parent=None, supports_count=None,
|
||||
supports_chains=False):
|
||||
super().__init__(parent, supports_count, supports_chains)
|
||||
self.commandmanager = CommandManager()
|
||||
self.commandrunner = CommandRunner()
|
||||
|
||||
def execute(self, cmdstr, _keytype, count=None):
|
||||
try:
|
||||
self.commandmanager.run(cmdstr, count)
|
||||
self.commandrunner.run(cmdstr, count)
|
||||
except (CommandMetaError, CommandError) as e:
|
||||
message.error(e, immediately=True)
|
||||
|
||||
|
@ -24,17 +24,17 @@ from functools import partial
|
||||
import qutebrowser.commands.utils as cmdutils
|
||||
from qutebrowser.utils.usertypes import Timer
|
||||
from qutebrowser.commands.exceptions import CommandError
|
||||
from qutebrowser.commands.managers import CommandManager
|
||||
from qutebrowser.commands.managers import CommandRunner
|
||||
|
||||
|
||||
_timers = []
|
||||
_commandmanager = None
|
||||
_commandrunner = None
|
||||
|
||||
|
||||
def init():
|
||||
"""Initialize the global _commandmanager."""
|
||||
global _commandmanager
|
||||
_commandmanager = CommandManager()
|
||||
"""Initialize the global _commandrunner."""
|
||||
global _commandrunner
|
||||
_commandrunner = CommandRunner()
|
||||
|
||||
|
||||
@cmdutils.register(nargs=(2, None))
|
||||
@ -57,6 +57,6 @@ def later(ms, *command):
|
||||
"representation.")
|
||||
_timers.append(timer)
|
||||
cmdline = ' '.join(command)
|
||||
timer.timeout.connect(partial(_commandmanager.run_safely, cmdline))
|
||||
timer.timeout.connect(partial(_commandrunner.run_safely, cmdline))
|
||||
timer.timeout.connect(lambda: _timers.remove(timer))
|
||||
timer.start()
|
||||
|
@ -26,7 +26,7 @@ from PyQt5.QtGui import QValidator
|
||||
import qutebrowser.keyinput.modeman as modeman
|
||||
import qutebrowser.commands.utils as cmdutils
|
||||
from qutebrowser.widgets.misc import MinimalLineEdit
|
||||
from qutebrowser.commands.managers import CommandManager
|
||||
from qutebrowser.commands.managers import CommandRunner
|
||||
from qutebrowser.keyinput.modeparsers import STARTCHARS
|
||||
from qutebrowser.utils.log import completion as logger
|
||||
from qutebrowser.models.cmdhistory import (History, HistoryEmptyError,
|
||||
@ -113,8 +113,8 @@ class Command(MinimalLineEdit):
|
||||
# Text is only whitespace so we treat this as a single element with
|
||||
# the whitespace.
|
||||
return [text]
|
||||
manager = CommandManager()
|
||||
parts = manager.parse(text, fallback=True, alias_no_args=False)
|
||||
runner = CommandRunner()
|
||||
parts = runner.parse(text, fallback=True, alias_no_args=False)
|
||||
if self._empty_item_idx is not None:
|
||||
logger.debug("Empty element queued at {}, inserting.".format(
|
||||
self._empty_item_idx))
|
||||
|
Loading…
Reference in New Issue
Block a user