console: keymap - list keys with modifiers separately

This commit is contained in:
Aldo Cortesi 2017-06-13 16:10:40 +12:00
parent 4a7cafee9e
commit 09128d9d1a
2 changed files with 7 additions and 4 deletions

View File

@ -1,6 +1,6 @@
def map(km):
km.add(":", "console.command ''", ["global"], "Command prompt")
km.add(":", "console.command ", ["global"], "Command prompt")
km.add("?", "console.view.help", ["global"], "View help")
km.add("C", "console.view.commands", ["global"], "View commands")
km.add("K", "console.view.keybindings", ["global"], "View key bindings")

View File

@ -60,9 +60,12 @@ class Keymap:
return None
def list(self, context: str) -> typing.Sequence[Binding]:
b = [b for b in self.bindings if context in b.contexts or context == "all"]
b.sort(key=lambda x: x.key)
return b
b = [x for x in self.bindings if context in x.contexts or context == "all"]
single = [x for x in b if len(x.key.split()) == 1]
multi = [x for x in b if len(x.key.split()) != 1]
single.sort(key=lambda x: x.key)
multi.sort(key=lambda x: x.key)
return single + multi
def handle(self, context: str, key: str) -> typing.Optional[str]:
"""