From 6917c3b32da179fd29ac374d4b3324e81193edc7 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 3 Apr 2015 17:10:14 +0200 Subject: [PATCH] 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. --- doc/help/commands.asciidoc | 5 ++++- qutebrowser/config/configdata.py | 18 ++++++++++-------- qutebrowser/mainwindow/statusbar/command.py | 5 ++++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index 3ad152b21..1e592cb61 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -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 -Syntax: +:set-cmd-text 'text'+ +Syntax: +:set-cmd-text [*--space*] 'text'+ Preset the statusbar to some text. ==== positional arguments * +'text'+: The commandline to set. +==== optional arguments +* +*-s*+, +*--space*+: If given, a space is added to the end. + [[spawn]] === spawn Syntax: +:spawn [*--userscript*] 'args' ['args' ...]+ diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index be45e9782..6807447be 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -1029,14 +1029,14 @@ KEY_DATA = collections.OrderedDict([ ('normal', collections.OrderedDict([ ('search ""', ['']), - ('set-cmd-text ":open "', ['o']), - ('set-cmd-text ":open {url}"', ['go']), - ('set-cmd-text ":open -t "', ['O']), - ('set-cmd-text ":open -t {url}"', ['gO']), - ('set-cmd-text ":open -b "', ['xo']), - ('set-cmd-text ":open -b {url}"', ['xO']), - ('set-cmd-text ":open -w "', ['wo']), - ('set-cmd-text ":open -w {url}"', ['wO']), + ('set-cmd-text -s :open', ['o']), + ('set-cmd-text :open {url}', ['go']), + ('set-cmd-text -s :open -t', ['O']), + ('set-cmd-text :open -t {url}', ['gO']), + ('set-cmd-text -s :open -b', ['xo']), + ('set-cmd-text :open -b {url}', ['xO']), + ('set-cmd-text -s :open -w', ['wo']), + ('set-cmd-text :open -w {url}', ['wO']), ('open -t', ['ga']), ('tab-close', ['d', '']), ('tab-close -o', ['D']), @@ -1189,4 +1189,6 @@ CHANGED_KEY_COMMANDS = [ (re.compile(r'^cancel-download$'), r'download-cancel'), (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'), ] diff --git a/qutebrowser/mainwindow/statusbar/command.py b/qutebrowser/mainwindow/statusbar/command.py index 38457b08b..48a106793 100644 --- a/qutebrowser/mainwindow/statusbar/command.py +++ b/qutebrowser/mainwindow/statusbar/command.py @@ -98,7 +98,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): @cmdutils.register(instance='status-command', name='set-cmd-text', 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. // @@ -108,6 +108,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): Args: text: The commandline to set. + space: If given, a space is added to the end. """ tabbed_browser = objreg.get('tabbed-browser', scope='window', 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 # https://github.com/The-Compiler/qutebrowser/issues/123 text = text.replace('{url}', url) + if space: + text += ' ' if not text or text[0] not in modeparsers.STARTCHARS: raise cmdexc.CommandError( "Invalid command text '{}'.".format(text))