From 01462008c9983d75c7e39d337bf25e06d97459eb Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 26 Feb 2018 22:48:32 +0100 Subject: [PATCH] Clearly separate yesno/prompt key modes --- qutebrowser/config/configdata.yml | 20 ++++++++++++-------- qutebrowser/keyinput/modeparsers.py | 4 +--- qutebrowser/mainwindow/prompt.py | 4 ++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml index d23682db8..7be015fd5 100644 --- a/qutebrowser/config/configdata.yml +++ b/qutebrowser/config/configdata.yml @@ -2379,8 +2379,6 @@ bindings.default: : leave-mode prompt: : prompt-accept - y: prompt-accept yes - n: prompt-accept no : prompt-open-download : prompt-item-focus prev : prompt-item-focus prev @@ -2403,6 +2401,14 @@ bindings.default: : rl-backward-delete-char : rl-yank : leave-mode + # FIXME can we do migrations? + yesno: + : prompt-accept + y: prompt-accept yes + n: prompt-accept no + : prompt-yank + : prompt-yank --sel + : leave-mode caret: v: toggle-selection : toggle-selection @@ -2438,7 +2444,7 @@ bindings.default: none_ok: true keytype: String # section name fixed_keys: ['normal', 'insert', 'hint', 'passthrough', 'command', - 'prompt', 'caret', 'register'] + 'prompt', 'yesno', 'caret', 'register'] valtype: name: Dict none_ok: true @@ -2462,7 +2468,7 @@ bindings.commands: none_ok: true keytype: String # section name fixed_keys: ['normal', 'insert', 'hint', 'passthrough', 'command', - 'prompt', 'caret', 'register'] + 'prompt', 'yesno', 'caret', 'register'] valtype: name: Dict none_ok: true @@ -2534,10 +2540,8 @@ bindings.commands: * prompt: Entered when there's a prompt to display, like for download locations or when invoked from JavaScript. - + - You can bind normal keys in this mode, but they will be only active when - a yes/no-prompt is asked. For other prompt modes, you can only bind - special keys. + + * yesno: Entered when there's a yes/no prompt displayed. * caret: Entered when pressing the `v` mode, used to select text using the keyboard. diff --git a/qutebrowser/keyinput/modeparsers.py b/qutebrowser/keyinput/modeparsers.py index 72f5c5027..0b196c23d 100644 --- a/qutebrowser/keyinput/modeparsers.py +++ b/qutebrowser/keyinput/modeparsers.py @@ -133,9 +133,7 @@ class PromptKeyParser(keyparser.CommandKeyParser): def __init__(self, win_id, parent=None): super().__init__(win_id, parent, supports_count=False, supports_chains=True) - # We don't want an extra section for this in the config, so we just - # abuse the prompt section. - self._read_config('prompt') + self._read_config('yesno') def __repr__(self): return utils.get_repr(self) diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py index 931d32654..90415b261 100644 --- a/qutebrowser/mainwindow/prompt.py +++ b/qutebrowser/mainwindow/prompt.py @@ -507,8 +507,8 @@ class _BasePrompt(QWidget): self._key_grid = QGridLayout() self._key_grid.setVerticalSpacing(0) - # The bindings are all in the 'prompt' mode, even for yesno prompts - all_bindings = config.key_instance.get_reverse_bindings_for('prompt') + all_bindings = config.key_instance.get_reverse_bindings_for( + self.KEY_MODE.name) labels = [] for cmd, text in self._allowed_commands():