forked from microsoft/terminal
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
Reviewer's Guide
Rewrites TerminalInput’s key handling to implement the Kitty Keyboard Protocol (KKP) on top of a new, shared encoding pipeline, wires new CSI u KKP control sequences through the VT parser/dispatch, adds settings and toggles in Terminal/ConPTY, and centralizes TAEF data-source helpers, with comprehensive unit tests verifying KKP behavior.
Updated class diagram for TerminalInput and Kitty keyboard protocol
classDiagram
class TerminalInput {
+TerminalInput()
+UseAlternateScreenBuffer() void
+UseMainScreenBuffer() void
+SetInputMode(Mode mode, bool enabled) void
+GetInputMode(Mode mode) bool
+ResetInputModes() void
+ForceDisableWin32InputMode(bool win32InputMode) void
+ForceDisableKittyKeyboardProtocol(bool disable) void
+SetKittyKeyboardProtocol(uint8_t flags, KittyKeyboardProtocolMode mode) void
+GetKittyFlags() uint8_t
+PushKittyFlags(uint8_t flags) void
+PopKittyFlags(size_t count) void
+ResetKittyKeyboardProtocols() void
+HandleKey(INPUT_RECORD event) OutputType
+HandleFocus(bool focused) OutputType
+_makeWin32Output(KEY_EVENT_RECORD key) OutputType
-_encodeKitty(KeyboardHelper kbd, EncodingHelper enc, SanitizedKeyEvent key) bool
-_encodeRegular(EncodingHelper enc, SanitizedKeyEvent key) void
-_formatEncodingHelper(EncodingHelper enc, wstring seq) bool
-_formatFallback(KeyboardHelper kbd, EncodingHelper enc, SanitizedKeyEvent key, wstring seq) void
-_stringPushCodepoint(wstring str, uint32_t cp) void
-_codepointToLower(uint32_t cp) uint32_t
-_trackControlKeyState(KEY_EVENT_RECORD key) DWORD
-_initKeyboardMap() void
-_leadingSurrogate wchar_t
-_lastVirtualKeyCode optional~WORD~
-_lastControlKeyState DWORD
-_lastLeftCtrlTime uint64_t
-_lastRightAltTime uint64_t
-_inputMode enumset~Mode~
-_forceDisableWin32InputMode bool
-_inAlternateBuffer bool
-KittyStackMaxSize size_t
-_forceDisableKittyKeyboardProtocol bool
-_kittyFlags uint8_t
-_kittyMainStack vector~uint8_t~
-_kittyAltStack vector~uint8_t~
-_csi wstring_view
-_ss3 wstring_view
-_focusInSequence wstring_view
-_focusOutSequence wstring_view
}
class KittyKeyboardProtocolFlags {
<<struct>>
+None uint8_t
+DisambiguateEscapeCodes uint8_t
+ReportEventTypes uint8_t
+ReportAlternateKeys uint8_t
+ReportAllKeysAsEscapeCodes uint8_t
+ReportAssociatedText uint8_t
+All uint8_t
}
class KittyKeyboardProtocolMode {
<<enum>>
Replace
Set
Reset
}
class SanitizedKeyEvent {
<<struct>>
+virtualKey uint16_t
+scanCode uint16_t
+codepoint uint32_t
+controlKeyState uint32_t
+leftCtrlIsReallyPressed bool
+keyDown bool
+keyRepeat bool
+anyAltPressed() bool
+bothAltPressed() bool
+rightAltPressed() bool
+bothCtrlPressed() bool
+altGrPressed() bool
}
class KeyboardHelper {
<<struct>>
+KeyboardHelper()
+getUnmodifiedKeyboardKey(SanitizedKeyEvent key) uint32_t
+getKittyBaseKey(SanitizedKeyEvent key) uint32_t
+getKittyShiftedKey(SanitizedKeyEvent key) uint32_t
+getKittyUSBaseKey(SanitizedKeyEvent key) uint32_t
-getKeyboardKey(UINT vkey, DWORD controlKeyState, HKL hkl) uint32_t
-init() void
-initSlow() void
-_initialized bool
-_keyboardLayout HKL
-_keyboardState uint8_t[256]
}
class EncodingHelper {
<<struct>>
+EncodingHelper()
+shiftPressed() bool
+altPressed() bool
+ctrlPressed() bool
+csiUnicodeKeyCode uint32_t
+csiAltKeyCodeShifted uint32_t
+csiAltKeyCodeBase uint32_t
+csiModifier uint32_t
+csiEventType uint32_t
+csiTextAsCodepoint uint32_t
+csiFinal wchar_t
+ss3Final wchar_t
+altPrefix bool
+plain wstring_view
}
class CodepointBuffer {
<<struct>>
+CodepointBuffer()
+CodepointBuffer(uint32_t cp)
+convertLowercase() void
+asSingleCodepoint() uint32_t
+buf wchar_t[4]
+len int
}
class ITermDispatch {
<<interface>>
+SetKittyKeyboardProtocol(VTParameter flags, VTParameter mode) void
+QueryKittyKeyboardProtocol() void
+PushKittyKeyboardProtocol(VTParameter flags) void
+PopKittyKeyboardProtocol(VTParameter count) void
}
class AdaptDispatch {
+SetKittyKeyboardProtocol(VTParameter flags, VTParameter mode) void
+QueryKittyKeyboardProtocol() void
+PushKittyKeyboardProtocol(VTParameter flags) void
+PopKittyKeyboardProtocol(VTParameter count) void
-_terminalInput TerminalInput
}
TerminalInput *-- KittyKeyboardProtocolFlags
TerminalInput *-- KittyKeyboardProtocolMode
TerminalInput *-- SanitizedKeyEvent
TerminalInput *-- KeyboardHelper
TerminalInput *-- EncodingHelper
TerminalInput *-- CodepointBuffer
AdaptDispatch ..|> ITermDispatch
AdaptDispatch o--> TerminalInput
File-Level Changes
| Change | Details | Files |
|---|---|---|
| Rewrite TerminalInput key handling around a new Kitty-aware encoding pipeline that prefers KKP over Win32/legacy VT and unifies surrogate, modifier, and keypad handling. |
|
src/terminal/input/terminalInput.cppsrc/terminal/input/terminalInput.hppsrc/terminal/input/sources.incsrc/terminal/input/lib/terminalinput.vcxprojsrc/terminal/input/mouseInput.cpp |
| Add full VT parser/dispatch support for Kitty Keyboard Protocol CSI u control sequences and integrate them with AdaptDispatch and TermDispatch. |
|
src/terminal/parser/OutputStateMachineEngine.hppsrc/terminal/parser/OutputStateMachineEngine.cppsrc/terminal/adapter/ITermDispatch.hppsrc/terminal/adapter/adaptDispatch.hppsrc/terminal/adapter/adaptDispatch.cppsrc/terminal/adapter/termDispatch.hpp |
| Expose configuration and host toggles for Kitty Keyboard Protocol in Terminal and ConPTY, and temporarily disable KKP behind ConPTY to avoid double-translation. |
|
src/cascadia/TerminalCore/Terminal.cppsrc/cascadia/TerminalCore/ICoreSettings.idlsrc/cascadia/TerminalSettingsModel/MTSMSettings.hsrc/cascadia/TerminalSettingsModel/Profile.idlsrc/cascadia/TerminalSettingsAppAdapterLib/TerminalSettings.cppsrc/cascadia/TerminalSettingsEditor/ProfileViewModel.hsrc/cascadia/TerminalSettingsEditor/ProfileViewModel.idlsrc/cascadia/TerminalSettingsEditor/Profiles_Terminal.xamlsrc/cascadia/TerminalSettingsEditor/Resources/en-US/Resources.reswsrc/cascadia/inc/ControlProperties.hsrc/host/VtIo.cpp |
| Refactor TAEF data source boilerplate into a shared helper and reuse it in existing test suites. |
|
src/inc/consoletaeftemplates.hppsrc/interactivity/win32/ut_interactivity_win32/UiaTextRangeTests.cppsrc/buffer/out/ut_textbuffer/ReflowTests.cpp |
| Add a comprehensive KKP unit test suite to validate Kitty Keyboard Protocol encoding of keys, modifiers, event types, keypad behavior, and alternate/associated text. |
|
src/terminal/adapter/ut_adapter/kittyKeyboardProtocol.cppsrc/terminal/adapter/ut_adapter/Adapter.UnitTests.vcxprojsrc/terminal/adapter/ut_adapter/Adapter.UnitTests.vcxproj.filterssrc/terminal/adapter/ut_adapter/sources |
Tips and commands
Interacting with Sourcery
- Trigger a new review: Comment
@sourcery-ai reviewon the pull request. - Continue discussions: Reply directly to Sourcery's review comments.
- Generate a GitHub issue from a review comment: Ask Sourcery to create an
issue from a review comment by replying to it. You can also reply to a
review comment with@sourcery-ai issueto create an issue from it. - Generate a pull request title: Write
@sourcery-aianywhere in the pull
request title to generate a title at any time. You can also comment
@sourcery-ai titleon the pull request to (re-)generate the title at any time. - Generate a pull request summary: Write
@sourcery-ai summaryanywhere in
the pull request body to generate a PR summary at any time exactly where you
want it. You can also comment@sourcery-ai summaryon the pull request to
(re-)generate the summary at any time. - Generate reviewer's guide: Comment
@sourcery-ai guideon the pull
request to (re-)generate the reviewer's guide at any time. - Resolve all Sourcery comments: Comment
@sourcery-ai resolveon the
pull request to resolve all Sourcery comments. Useful if you've already
addressed all the comments and don't want to see them anymore. - Dismiss all Sourcery reviews: Comment
@sourcery-ai dismisson the pull
request to dismiss all existing Sourcery reviews. Especially useful if you
want to start fresh with a new review - don't forget to comment
@sourcery-ai reviewto trigger a new review!
Customizing Your Experience
Access your dashboard to:
- Enable or disable review features such as the Sourcery-generated pull request
summary, the reviewer's guide, and others. - Change the review language.
- Add, remove or edit custom review instructions.
- Adjust other review settings.
Getting Help
- Contact our support team for questions or feedback.
- Visit our documentation for detailed guides and information.
- Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.
Originally posted by @sourcery-ai[bot] in #7 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Projects
Status
Backlog
Status
Todo