Merge branch 'rcorre-command_binding_completion'
This commit is contained in:
commit
9111d1b10f
@ -186,3 +186,7 @@ def init():
|
|||||||
history = objreg.get('web-history')
|
history = objreg.get('web-history')
|
||||||
history.async_read_done.connect(
|
history.async_read_done.connect(
|
||||||
functools.partial(update, [usertypes.Completion.url]))
|
functools.partial(update, [usertypes.Completion.url]))
|
||||||
|
|
||||||
|
keyconf = objreg.get('key-config')
|
||||||
|
keyconf.changed.connect(
|
||||||
|
functools.partial(update, [usertypes.Completion.command]))
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
"""Misc. CompletionModels."""
|
"""Misc. CompletionModels."""
|
||||||
|
|
||||||
|
from collections import defaultdict
|
||||||
from PyQt5.QtCore import Qt, QTimer, pyqtSlot
|
from PyQt5.QtCore import Qt, QTimer, pyqtSlot
|
||||||
|
|
||||||
from qutebrowser.browser import webview
|
from qutebrowser.browser import webview
|
||||||
@ -35,6 +36,8 @@ class CommandCompletionModel(base.BaseCompletionModel):
|
|||||||
# https://github.com/The-Compiler/qutebrowser/issues/545
|
# https://github.com/The-Compiler/qutebrowser/issues/545
|
||||||
# pylint: disable=abstract-method
|
# pylint: disable=abstract-method
|
||||||
|
|
||||||
|
COLUMN_WIDTHS = (20, 60, 20)
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
assert cmdutils.cmd_dict
|
assert cmdutils.cmd_dict
|
||||||
@ -48,8 +51,18 @@ class CommandCompletionModel(base.BaseCompletionModel):
|
|||||||
for name, cmd in config.section('aliases').items():
|
for name, cmd in config.section('aliases').items():
|
||||||
cmdlist.append((name, "Alias for '{}'".format(cmd)))
|
cmdlist.append((name, "Alias for '{}'".format(cmd)))
|
||||||
cat = self.new_category("Commands")
|
cat = self.new_category("Commands")
|
||||||
|
|
||||||
|
# map each command to its bound keys and show these in the misc column
|
||||||
|
keyconf = objreg.get('key-config')
|
||||||
|
cmd_to_keys = defaultdict(list)
|
||||||
|
for key, cmd in keyconf.get_bindings_for('normal').items():
|
||||||
|
# put special bindings last
|
||||||
|
if key.startswith('<') and key.endswith('>'):
|
||||||
|
cmd_to_keys[cmd].append(key)
|
||||||
|
else:
|
||||||
|
cmd_to_keys[cmd].insert(0, key)
|
||||||
for (name, desc) in sorted(cmdlist):
|
for (name, desc) in sorted(cmdlist):
|
||||||
self.new_item(cat, name, desc)
|
self.new_item(cat, name, desc, ', '.join(cmd_to_keys[name]))
|
||||||
|
|
||||||
|
|
||||||
class HelpCompletionModel(base.BaseCompletionModel):
|
class HelpCompletionModel(base.BaseCompletionModel):
|
||||||
|
Loading…
Reference in New Issue
Block a user