microsoft/Terminal

Support "Key Chords" in keybindings

Open

#1.334 aberto em 19 de jun. de 2019

Ver no GitHub
 (15 comments) (38 reactions) (0 assignees)C++ (3.212 forks)batch import
Area-SettingsHelp WantedIssue-FeatureProduct-Terminal

Métricas do repositório

Stars
 (35.764 stars)
Métricas de merge de PR
 (Mesclagem média 27d 19h) (24 fundiu PRs em 30d)

Description

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?

Guia do colaborador