Hi, @herr.kaste!
Topic: KeyBindingReport Package under development
Here is what I have come up with so far as regards key-binding reports that would be useful (to me, plus an additional use case or 2 that made sense). (In the below, what appear to be arguments intentionally exclude self and edit for the sake of brevity.)
Given:
from enum import IntEnum
class KeyGroup(IntEnum):
""" Non-negative values index into a list of lists of key names. """
ALL_KEYS = -3
SPECIFIED_KEY = -2
KEY_SEQUENCES = -1 # Multiple-key-press sequences, e.g. ["ctrl+k", "ctrl+u"]
LETTER_KEYS = 0
NUMBER_KEYS = 1
SYMBOL_KEYS = 2
NAMED_KEYS = 3
KEYPAD_KEYS = 4
F_KEYS = 5
class Format(IntEnum):
""" Formats supported by Generator (from ascii_table.py) """
BARE = 0
OUTLINED = 1
RESTRUCTUREDTEXT = 2
KeyBindingReportCommand(package, key_group, key, format)
Generate key-binding tables in format format based on limiting criteria from pkg, key_group and key.
-
By Package. Output all key bindings contained in Package (e.g. Default or a 3rd-party Package). This also implies that the look-up data structures can also be limited to that Package.
-
By specified key. Output that key’s bindings in all Packages that contain binding(s) for that key.
-
By specified key limited to Default Package. Output all of key’s binding(s).
-
By specified KeyGroup, using bindings from all Packages. (See below for definition of KeyGroup.)
-
By specified KeyGroup, limited to Default Package. (See below for definition of KeyGroup.)
KeyBindingReportWhichBindingCommand([“tab”])
Report which key binding is selected for a specified key-press or key sequence the same way Sublime Text selects it: reverse search selecting first binding where current scope matches key context.
Can you think of any more groupings or filters that would be useful to you?
Kind regards,
Vic
P.S. You asked earlier about a “current scope” scenario, but the only use case I think think of for that is for a particular key-press, as opposed to a “whole table” of bindings, where each key only has 1 binding for the current scope. I can’t think of anything I would use that for, so I concluded that providing it for 1 key-press was the one use case that made sense. Do you concur?
P.P.S. Afterthought: if I generalize it like this, then it is bound to take care of ALL POSSIBLE use cases, including those I had not thought of:
KeyBindingReportWhichBindingCommand
This command reports on the key bindings that Sublime Text would select given the current scope of the current View for a specified list of key presses and/or key-press sequences.
KeyBindingReportCommand
This command reports on all the key bindings for a set of keys which may be limited to:
- a specified list of key names,
- a specified list of key groups (e.g. F_KEYS),
- a specified list of Packages, or
- combinations of the above
with an option for output format and whether to show unbound key combinations.
P.P.P.S. Plus output options in a flags argument:
class FlagBits(IntFlag):
SHOW_UNBOUND_KEY_COMBINATIONS = 0b00000001
SHOW_PACKAGE_NAME = 0b00000010
ADD_COMMENTS_COLUMN = 0b00000100
INCLUDE_UNTRANSLATED_CONTEXTS = 0b00001000
INCLUDE_ENGLISH_CONTEXTS = 0b00010000
At this point, adding broad flexibility doesn’t cost anything.