set-cmd-text: Add -s/--space argument.
We need this because quotes are ignored now, so there'd be no way to set the text to ":open -t " for example.
This commit is contained in:
parent
3b3b55234b
commit
6917c3b32d
@ -463,13 +463,16 @@ If the option name ends with '?', the value of the option is shown instead. If t
|
|||||||
|
|
||||||
[[set-cmd-text]]
|
[[set-cmd-text]]
|
||||||
=== set-cmd-text
|
=== set-cmd-text
|
||||||
Syntax: +:set-cmd-text 'text'+
|
Syntax: +:set-cmd-text [*--space*] 'text'+
|
||||||
|
|
||||||
Preset the statusbar to some text.
|
Preset the statusbar to some text.
|
||||||
|
|
||||||
==== positional arguments
|
==== positional arguments
|
||||||
* +'text'+: The commandline to set.
|
* +'text'+: The commandline to set.
|
||||||
|
|
||||||
|
==== optional arguments
|
||||||
|
* +*-s*+, +*--space*+: If given, a space is added to the end.
|
||||||
|
|
||||||
[[spawn]]
|
[[spawn]]
|
||||||
=== spawn
|
=== spawn
|
||||||
Syntax: +:spawn [*--userscript*] 'args' ['args' ...]+
|
Syntax: +:spawn [*--userscript*] 'args' ['args' ...]+
|
||||||
|
@ -1029,14 +1029,14 @@ KEY_DATA = collections.OrderedDict([
|
|||||||
|
|
||||||
('normal', collections.OrderedDict([
|
('normal', collections.OrderedDict([
|
||||||
('search ""', ['<Escape>']),
|
('search ""', ['<Escape>']),
|
||||||
('set-cmd-text ":open "', ['o']),
|
('set-cmd-text -s :open', ['o']),
|
||||||
('set-cmd-text ":open {url}"', ['go']),
|
('set-cmd-text :open {url}', ['go']),
|
||||||
('set-cmd-text ":open -t "', ['O']),
|
('set-cmd-text -s :open -t', ['O']),
|
||||||
('set-cmd-text ":open -t {url}"', ['gO']),
|
('set-cmd-text :open -t {url}', ['gO']),
|
||||||
('set-cmd-text ":open -b "', ['xo']),
|
('set-cmd-text -s :open -b', ['xo']),
|
||||||
('set-cmd-text ":open -b {url}"', ['xO']),
|
('set-cmd-text :open -b {url}', ['xO']),
|
||||||
('set-cmd-text ":open -w "', ['wo']),
|
('set-cmd-text -s :open -w', ['wo']),
|
||||||
('set-cmd-text ":open -w {url}"', ['wO']),
|
('set-cmd-text :open -w {url}', ['wO']),
|
||||||
('open -t', ['ga']),
|
('open -t', ['ga']),
|
||||||
('tab-close', ['d', '<Ctrl-W>']),
|
('tab-close', ['d', '<Ctrl-W>']),
|
||||||
('tab-close -o', ['D']),
|
('tab-close -o', ['D']),
|
||||||
@ -1189,4 +1189,6 @@ CHANGED_KEY_COMMANDS = [
|
|||||||
(re.compile(r'^cancel-download$'), r'download-cancel'),
|
(re.compile(r'^cancel-download$'), r'download-cancel'),
|
||||||
(re.compile(r'^search ""$'), r'search'),
|
(re.compile(r'^search ""$'), r'search'),
|
||||||
(re.compile(r"^search ''$"), r'search'),
|
(re.compile(r"^search ''$"), r'search'),
|
||||||
|
(re.compile(r"""^set-cmd-text ['"](.*) ['"]$"""), r'set-cmd-text -s \1'),
|
||||||
|
(re.compile(r"""^set-cmd-text ['"](.*)['"]$"""), r'set-cmd-text \1'),
|
||||||
]
|
]
|
||||||
|
@ -98,7 +98,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
|
|
||||||
@cmdutils.register(instance='status-command', name='set-cmd-text',
|
@cmdutils.register(instance='status-command', name='set-cmd-text',
|
||||||
scope='window', maxsplit=0)
|
scope='window', maxsplit=0)
|
||||||
def set_cmd_text_command(self, text):
|
def set_cmd_text_command(self, text, space=False):
|
||||||
"""Preset the statusbar to some text.
|
"""Preset the statusbar to some text.
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -108,6 +108,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
text: The commandline to set.
|
text: The commandline to set.
|
||||||
|
space: If given, a space is added to the end.
|
||||||
"""
|
"""
|
||||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||||
window=self._win_id)
|
window=self._win_id)
|
||||||
@ -127,6 +128,8 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
|
|||||||
# I'm not sure what's the best thing to do here
|
# I'm not sure what's the best thing to do here
|
||||||
# https://github.com/The-Compiler/qutebrowser/issues/123
|
# https://github.com/The-Compiler/qutebrowser/issues/123
|
||||||
text = text.replace('{url}', url)
|
text = text.replace('{url}', url)
|
||||||
|
if space:
|
||||||
|
text += ' '
|
||||||
if not text or text[0] not in modeparsers.STARTCHARS:
|
if not text or text[0] not in modeparsers.STARTCHARS:
|
||||||
raise cmdexc.CommandError(
|
raise cmdexc.CommandError(
|
||||||
"Invalid command text '{}'.".format(text))
|
"Invalid command text '{}'.".format(text))
|
||||||
|
Loading…
Reference in New Issue
Block a user