Add --append argument to :set-cmd-text.

This commit is contained in:
Florian Bruhin 2015-11-10 19:21:54 +01:00
parent cd25a25c96
commit 7701bf602a
3 changed files with 12 additions and 2 deletions

View File

@ -48,6 +48,8 @@ Added
* `colors -> downloads.bg.system`
- New command `:download-retry` to retry a failed download.
- New command `:download-clear` which replaces `:download-remove --all`.
- `:set-cmd-text` has a new `--append` argument to append to the current
statusbar text.
Changed
~~~~~~~

View File

@ -571,7 +571,7 @@ 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 [*--space*] 'text'+
Syntax: +:set-cmd-text [*--space*] [*--append*] 'text'+
Preset the statusbar to some text.
@ -580,6 +580,7 @@ Preset the statusbar to some text.
==== optional arguments
* +*-s*+, +*--space*+: If given, a space is added to the end.
* +*-a*+, +*--append*+: If given, the text is appended to the current text.
==== note
* This command does not split arguments after the last argument and handles quotes literally.

View File

@ -92,7 +92,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, space=False):
def set_cmd_text_command(self, text, space=False, append=False):
"""Preset the statusbar to some text.
//
@ -103,6 +103,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit):
Args:
text: The commandline to set.
space: If given, a space is added to the end.
append: If given, the text is appended to the current text.
"""
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=self._win_id)
@ -122,8 +123,14 @@ 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 append:
if not self.text():
raise cmdexc.CommandError("No current text!")
text = self.text() + text
if not text or text[0] not in modeparsers.STARTCHARS:
raise cmdexc.CommandError(
"Invalid command text '{}'.".format(text))