microsoft/Terminal

Support "Key Chords" in keybindings

Open

#1334 aperta il 19 giu 2019

Vedi su GitHub
 (15 commenti) (38 reazioni) (0 assegnatari)C++ (3212 fork)batch import
Area-SettingsHelp WantedIssue-FeatureProduct-Terminal

Metriche repository

Star
 (35.764 star)
Metriche merge PR
 (Merge medio 27g 19h) (24 PR mergiate in 30 g)

Descrizione

Currently, we only support pressing a single key+modifiers to activate a keybinding action.

However, many text editors support "key chords" where the chord is a combination of multiple keys pressed in sequence. For example, in Visual Studio, the default keybinding for "Comment Code" is the chord [ctrl+c, ctrl+k].

We've already prepared for serializing these chords in the array of keybindings, but we don't support more than one key at a time. We'd have somehow check if a key is the start of a chord, and only dispatch the action when all keys for the chord have been pressed.

Lots of questions:

  • What happens if an action is bound to [ctrl+c, ctrl+k] and another is bound to [ctrl+c]?
  • If the first key of a chord is pressed, but the second key isn't bound to an action, should we write both keys to the input?
  • If the first key of a chord is pressed, but then nothing is pressed for a long time, should we time out?
  • What's the best way of finding the right keybinding for a chord?
    • Iterating over all of them when a key is pressed, until the chord is dispatched seems awful (but trivial to do).
    • Maybe we could build a tree of keychords, or a list of trees?
    • My CS542 senses are tingling and suggesting that this might be the case to use a state machine.
      • Is a state machine really different than a tree in this case?

Guida contributor