Clearly separate yesno/prompt key modes

This commit is contained in:
Florian Bruhin 2018-02-26 22:48:32 +01:00
parent d9ae3fd5aa
commit 01462008c9
3 changed files with 15 additions and 13 deletions

View File

@ -2379,8 +2379,6 @@ bindings.default:
<Escape>: leave-mode
prompt:
<Return>: prompt-accept
y: prompt-accept yes
n: prompt-accept no
<Ctrl-X>: prompt-open-download
<Shift-Tab>: prompt-item-focus prev
<Up>: prompt-item-focus prev
@ -2403,6 +2401,14 @@ bindings.default:
<Ctrl-H>: rl-backward-delete-char
<Ctrl-Y>: rl-yank
<Escape>: leave-mode
# FIXME can we do migrations?
yesno:
<Return>: prompt-accept
y: prompt-accept yes
n: prompt-accept no
<Alt-Y>: prompt-yank
<Alt-Shift-Y>: prompt-yank --sel
<Escape>: leave-mode
caret:
v: toggle-selection
<Space>: 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.

View File

@ -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)

View File

@ -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():