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