Use object registry for keyparsers.
This commit is contained in:
parent
c77057e88e
commit
df5ac3ab2f
@ -55,7 +55,6 @@ class Application(QApplication):
|
|||||||
Attributes:
|
Attributes:
|
||||||
_args: ArgumentParser instance.
|
_args: ArgumentParser instance.
|
||||||
_commandrunner: The main CommandRunner instance.
|
_commandrunner: The main CommandRunner instance.
|
||||||
_keyparsers: A mapping from modes to keyparsers.
|
|
||||||
_shutting_down: True if we're currently shutting down.
|
_shutting_down: True if we're currently shutting down.
|
||||||
_quit_status: The current quitting status.
|
_quit_status: The current quitting status.
|
||||||
_crashdlg: The crash dialog currently open.
|
_crashdlg: The crash dialog currently open.
|
||||||
@ -83,7 +82,6 @@ class Application(QApplication):
|
|||||||
}
|
}
|
||||||
objreg.register('app', self)
|
objreg.register('app', self)
|
||||||
self._shutting_down = False
|
self._shutting_down = False
|
||||||
self._keyparsers = None
|
|
||||||
self._crashdlg = None
|
self._crashdlg = None
|
||||||
self._crashlogfile = None
|
self._crashlogfile = None
|
||||||
|
|
||||||
@ -209,7 +207,7 @@ class Application(QApplication):
|
|||||||
|
|
||||||
def _init_modes(self):
|
def _init_modes(self):
|
||||||
"""Inizialize the mode manager and the keyparsers."""
|
"""Inizialize the mode manager and the keyparsers."""
|
||||||
self._keyparsers = {
|
keyparsers = {
|
||||||
utypes.KeyMode.normal:
|
utypes.KeyMode.normal:
|
||||||
modeparsers.NormalKeyParser(self),
|
modeparsers.NormalKeyParser(self),
|
||||||
utypes.KeyMode.hint:
|
utypes.KeyMode.hint:
|
||||||
@ -225,27 +223,28 @@ class Application(QApplication):
|
|||||||
utypes.KeyMode.yesno:
|
utypes.KeyMode.yesno:
|
||||||
modeparsers.PromptKeyParser(self),
|
modeparsers.PromptKeyParser(self),
|
||||||
}
|
}
|
||||||
|
objreg.register('keyparsers', keyparsers)
|
||||||
mode_manager = modeman.ModeManager(self)
|
mode_manager = modeman.ModeManager(self)
|
||||||
objreg.register('mode-manager', mode_manager)
|
objreg.register('mode-manager', mode_manager)
|
||||||
mode_manager.register(utypes.KeyMode.normal,
|
mode_manager.register(utypes.KeyMode.normal,
|
||||||
self._keyparsers[utypes.KeyMode.normal].handle)
|
keyparsers[utypes.KeyMode.normal].handle)
|
||||||
mode_manager.register(utypes.KeyMode.hint,
|
mode_manager.register(utypes.KeyMode.hint,
|
||||||
self._keyparsers[utypes.KeyMode.hint].handle)
|
keyparsers[utypes.KeyMode.hint].handle)
|
||||||
mode_manager.register(utypes.KeyMode.insert,
|
mode_manager.register(utypes.KeyMode.insert,
|
||||||
self._keyparsers[utypes.KeyMode.insert].handle,
|
keyparsers[utypes.KeyMode.insert].handle,
|
||||||
passthrough=True)
|
passthrough=True)
|
||||||
mode_manager.register(
|
mode_manager.register(
|
||||||
utypes.KeyMode.passthrough,
|
utypes.KeyMode.passthrough,
|
||||||
self._keyparsers[utypes.KeyMode.passthrough].handle,
|
keyparsers[utypes.KeyMode.passthrough].handle,
|
||||||
passthrough=True)
|
passthrough=True)
|
||||||
mode_manager.register(utypes.KeyMode.command,
|
mode_manager.register(utypes.KeyMode.command,
|
||||||
self._keyparsers[utypes.KeyMode.command].handle,
|
keyparsers[utypes.KeyMode.command].handle,
|
||||||
passthrough=True)
|
passthrough=True)
|
||||||
mode_manager.register(utypes.KeyMode.prompt,
|
mode_manager.register(utypes.KeyMode.prompt,
|
||||||
self._keyparsers[utypes.KeyMode.prompt].handle,
|
keyparsers[utypes.KeyMode.prompt].handle,
|
||||||
passthrough=True)
|
passthrough=True)
|
||||||
mode_manager.register(utypes.KeyMode.yesno,
|
mode_manager.register(utypes.KeyMode.yesno,
|
||||||
self._keyparsers[utypes.KeyMode.yesno].handle)
|
keyparsers[utypes.KeyMode.yesno].handle)
|
||||||
|
|
||||||
def _init_misc(self):
|
def _init_misc(self):
|
||||||
"""Initialize misc things."""
|
"""Initialize misc things."""
|
||||||
@ -369,7 +368,7 @@ class Application(QApplication):
|
|||||||
"""Connect all signals to their slots."""
|
"""Connect all signals to their slots."""
|
||||||
# pylint: disable=too-many-statements, too-many-locals
|
# pylint: disable=too-many-statements, too-many-locals
|
||||||
# syntactic sugar
|
# syntactic sugar
|
||||||
kp = self._keyparsers
|
kp = objreg.get('keyparsers')
|
||||||
main_window = objreg.get('main-window')
|
main_window = objreg.get('main-window')
|
||||||
status = main_window.status
|
status = main_window.status
|
||||||
completion = objreg.get('completion')
|
completion = objreg.get('completion')
|
||||||
|
Loading…
Reference in New Issue
Block a user