summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2022-03-29 11:33:56 +0200
committerFlorian Bruhin <me@the-compiler.org>2022-03-29 11:33:56 +0200
commite93cb0a00d1d05f279b49ec428f67df54e7aceae (patch)
tree8960787d076fa0c4a7dee0becf662c16495c5d60
parent70d83cb627eb7437779ec0bf37e323d55e7d315a (diff)
downloadqutebrowser-e93cb0a00d1d05f279b49ec428f67df54e7aceae.tar.gz
qutebrowser-e93cb0a00d1d05f279b49ec428f67df54e7aceae.zip
Show unbound prompt bindings
This makes new commands more discoverable for people with custom bindings, and helps in situations like https://www.reddit.com/r/qutebrowser/comments/tq7628/prompt_trap_closing_the_application_is_the_only/
-rw-r--r--qutebrowser/mainwindow/prompt.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py
index c8cbe572b..29ea9a45f 100644
--- a/qutebrowser/mainwindow/prompt.py
+++ b/qutebrowser/mainwindow/prompt.py
@@ -536,9 +536,11 @@ class _BasePrompt(QWidget):
self.KEY_MODE.name)
labels = []
+ has_bindings = False
for cmd, text in self._allowed_commands():
bindings = all_bindings.get(cmd, [])
if bindings:
+ has_bindings = True
binding = None
preferred = ['<enter>', '<escape>']
for pref in preferred:
@@ -547,8 +549,11 @@ class _BasePrompt(QWidget):
if binding is None:
binding = bindings[0]
key_label = QLabel('<b>{}</b>'.format(html.escape(binding)))
- text_label = QLabel(text)
- labels.append((key_label, text_label))
+ else:
+ key_label = QLabel(f'<b>unbound</b> (<tt>{html.escape(cmd)}</tt>)')
+
+ text_label = QLabel(text)
+ labels.append((key_label, text_label))
for i, (key_label, text_label) in enumerate(labels):
self._key_grid.addWidget(key_label, i, 0)
@@ -559,6 +564,14 @@ class _BasePrompt(QWidget):
self._vbox.addLayout(self._key_grid)
+ if not has_bindings:
+ label = QLabel(
+ "<b>Note:</b> You seem to have unbound all keys for this prompt "
+ f"(<tt>{self.KEY_MODE.name}</tt> key mode)."
+ "<br/>Run <tt>qutebrowser :CMD</tt> with a command from above to "
+ "close this prompt, then fix this in your config.")
+ self._vbox.addWidget(label)
+
def _check_save_support(self, save):
if save:
raise UnsupportedOperationError("Saving answers is only possible "