parent
46d1760798
commit
20f0ef7ccc
@ -758,7 +758,8 @@ class Application(QApplication):
|
|||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@cmdutils.register(instance='app', maxsplit=0, debug=True)
|
@cmdutils.register(instance='app', maxsplit=0, debug=True,
|
||||||
|
no_cmd_split=True)
|
||||||
def debug_pyeval(self, s):
|
def debug_pyeval(self, s):
|
||||||
"""Evaluate a python string and display the results as a web page.
|
"""Evaluate a python string and display the results as a web page.
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ class register: # pylint: disable=invalid-name
|
|||||||
def __init__(self, instance=None, name=None, maxsplit=None, hide=False,
|
def __init__(self, instance=None, name=None, maxsplit=None, hide=False,
|
||||||
completion=None, modes=None, not_modes=None, needs_js=False,
|
completion=None, modes=None, not_modes=None, needs_js=False,
|
||||||
debug=False, ignore_args=False, deprecated=False,
|
debug=False, ignore_args=False, deprecated=False,
|
||||||
scope='global'):
|
no_cmd_split=False, scope='global'):
|
||||||
"""Save decorator arguments.
|
"""Save decorator arguments.
|
||||||
|
|
||||||
Gets called on parse-time with the decorator arguments.
|
Gets called on parse-time with the decorator arguments.
|
||||||
@ -139,6 +139,7 @@ class register: # pylint: disable=invalid-name
|
|||||||
self._deprecated = deprecated
|
self._deprecated = deprecated
|
||||||
self._debug = debug
|
self._debug = debug
|
||||||
self._ignore_args = ignore_args
|
self._ignore_args = ignore_args
|
||||||
|
self._no_cmd_split = no_cmd_split
|
||||||
if modes is not None:
|
if modes is not None:
|
||||||
for m in modes:
|
for m in modes:
|
||||||
if not isinstance(m, usertypes.KeyMode):
|
if not isinstance(m, usertypes.KeyMode):
|
||||||
@ -196,7 +197,8 @@ class register: # pylint: disable=invalid-name
|
|||||||
completion=self._completion, modes=self._modes,
|
completion=self._completion, modes=self._modes,
|
||||||
not_modes=self._not_modes, needs_js=self._needs_js,
|
not_modes=self._not_modes, needs_js=self._needs_js,
|
||||||
is_debug=self._debug, ignore_args=self._ignore_args,
|
is_debug=self._debug, ignore_args=self._ignore_args,
|
||||||
deprecated=self._deprecated, handler=func)
|
deprecated=self._deprecated, no_cmd_split=self._no_cmd_split,
|
||||||
|
handler=func)
|
||||||
for name in names:
|
for name in names:
|
||||||
cmd_dict[name] = cmd
|
cmd_dict[name] = cmd
|
||||||
aliases += names[1:]
|
aliases += names[1:]
|
||||||
|
@ -46,6 +46,7 @@ class Command:
|
|||||||
special_params: A dict with the names of the special parameters as
|
special_params: A dict with the names of the special parameters as
|
||||||
values.
|
values.
|
||||||
flags_with_args: A list of flags which take an argument.
|
flags_with_args: A list of flags which take an argument.
|
||||||
|
no_cmd_split: If true, ';;' to split sub-commands is ignored.
|
||||||
_type_conv: A mapping of conversion functions for arguments.
|
_type_conv: A mapping of conversion functions for arguments.
|
||||||
_name_conv: A mapping of argument names to parameter names.
|
_name_conv: A mapping of argument names to parameter names.
|
||||||
_needs_js: Whether the command needs javascript enabled
|
_needs_js: Whether the command needs javascript enabled
|
||||||
@ -65,7 +66,7 @@ class Command:
|
|||||||
|
|
||||||
def __init__(self, name, maxsplit, hide, instance, completion, modes,
|
def __init__(self, name, maxsplit, hide, instance, completion, modes,
|
||||||
not_modes, needs_js, is_debug, ignore_args, deprecated,
|
not_modes, needs_js, is_debug, ignore_args, deprecated,
|
||||||
handler, scope):
|
no_cmd_split, handler, scope):
|
||||||
# I really don't know how to solve this in a better way, I tried.
|
# I really don't know how to solve this in a better way, I tried.
|
||||||
# pylint: disable=too-many-arguments,too-many-locals
|
# pylint: disable=too-many-arguments,too-many-locals
|
||||||
self.name = name
|
self.name = name
|
||||||
@ -81,6 +82,7 @@ class Command:
|
|||||||
self.debug = is_debug
|
self.debug = is_debug
|
||||||
self.ignore_args = ignore_args
|
self.ignore_args = ignore_args
|
||||||
self.handler = handler
|
self.handler = handler
|
||||||
|
self.no_cmd_split = no_cmd_split
|
||||||
self.docparser = docutils.DocstringParser(handler)
|
self.docparser = docutils.DocstringParser(handler)
|
||||||
self.parser = argparser.ArgumentParser(
|
self.parser = argparser.ArgumentParser(
|
||||||
name, description=self.docparser.short_desc,
|
name, description=self.docparser.short_desc,
|
||||||
|
@ -279,11 +279,14 @@ class CommandRunner(QObject):
|
|||||||
text: The text to parse.
|
text: The text to parse.
|
||||||
count: The count to pass to the command.
|
count: The count to pass to the command.
|
||||||
"""
|
"""
|
||||||
if ';;' in text:
|
|
||||||
for sub in text.split(';;'):
|
|
||||||
self.run(sub, count)
|
|
||||||
return
|
|
||||||
self.parse(text)
|
self.parse(text)
|
||||||
|
if ';;' in text:
|
||||||
|
# Get the first command and check if it doesn't want to have ;;
|
||||||
|
# split.
|
||||||
|
if not self._cmd.no_cmd_split:
|
||||||
|
for sub in text.split(';;'):
|
||||||
|
self.run(sub, count)
|
||||||
|
return
|
||||||
args = replace_variables(self._win_id, self._args)
|
args = replace_variables(self._win_id, self._args)
|
||||||
if count is not None:
|
if count is not None:
|
||||||
self._cmd.run(self._win_id, args, count=count)
|
self._cmd.run(self._win_id, args, count=count)
|
||||||
|
@ -139,7 +139,7 @@ class KeyConfigParser(QObject):
|
|||||||
data = str(self)
|
data = str(self)
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
@cmdutils.register(instance='key-config', maxsplit=1)
|
@cmdutils.register(instance='key-config', maxsplit=1, no_cmd_split=True)
|
||||||
def bind(self, key, command, *, mode=None, force=False):
|
def bind(self, key, command, *, mode=None, force=False):
|
||||||
"""Bind a key to a command.
|
"""Bind a key to a command.
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ from qutebrowser.config import style
|
|||||||
from qutebrowser.misc import consolewidget
|
from qutebrowser.misc import consolewidget
|
||||||
|
|
||||||
|
|
||||||
@cmdutils.register(scope='window', maxsplit=1)
|
@cmdutils.register(scope='window', maxsplit=1, no_cmd_split=True)
|
||||||
def later(ms: {'type': int}, command, win_id: {'special': 'win_id'}):
|
def later(ms: {'type': int}, command, win_id: {'special': 'win_id'}):
|
||||||
"""Execute a command after some time.
|
"""Execute a command after some time.
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ def later(ms: {'type': int}, command, win_id: {'special': 'win_id'}):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
@cmdutils.register(scope='window', maxsplit=1)
|
@cmdutils.register(scope='window', maxsplit=1, no_cmd_split=True)
|
||||||
def repeat(times: {'type': int}, command, win_id: {'special': 'win_id'}):
|
def repeat(times: {'type': int}, command, win_id: {'special': 'win_id'}):
|
||||||
"""Repeat a given command.
|
"""Repeat a given command.
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ def debug_console():
|
|||||||
con_widget.show()
|
con_widget.show()
|
||||||
|
|
||||||
|
|
||||||
@cmdutils.register(debug=True, maxsplit=0)
|
@cmdutils.register(debug=True, maxsplit=0, no_cmd_split=True)
|
||||||
def debug_trace(expr=""):
|
def debug_trace(expr=""):
|
||||||
"""Trace executed code via hunter.
|
"""Trace executed code via hunter.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user