microsoft/Terminal

Support "Key Chords" in keybindings

Open

#1,334 创建于 2019年6月19日

在 GitHub 查看
 (15 评论) (38 反应) (0 负责人)C++ (3,212 fork)batch import
Area-SettingsHelp WantedIssue-FeatureProduct-Terminal

仓库指标

Star
 (35,764 star)
PR 合并指标
 (平均合并 27天 19小时) (30 天内合并 24 个 PR)

描述

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?

贡献者指南