Skip to content

V2 4893 kitty keyboard shifted fix - #4894

Merged
tig merged 7 commits into
tui-cs:developfrom
BDisp:v2_4893_kitty-keyboard-shifted-fix
Apr 8, 2026
Merged

V2 4893 kitty keyboard shifted fix#4894
tig merged 7 commits into
tui-cs:developfrom
BDisp:v2_4893_kitty-keyboard-shifted-fix

Conversation

@BDisp

@BDisp BDisp commented Apr 7, 2026

Copy link
Copy Markdown
Collaborator

Fixes

Proposed Changes/Todos

  • Enable kitty ReportAssociatedText support in the requested keyboard flags.
  • Parse kitty associated-text payloads and carry them through Key.
  • Prefer associated text, then shifted kitty metadata, when resolving printable text from Key.
  • Normalize shifted printable kitty sequences so input like shifted digits inserts the produced character instead of the physical key code.
  • Add and update parser, keyboard, TextField, TextView, and TextValidateField tests to cover shifted printable behavior and associated text handling.

Pull Request checklist:

  • I've named my PR in the form of "Fixes #issue. Terse description."
  • My code follows the style guidelines of Terminal.Gui - if you use Visual Studio, hit CTRL-K-D to automatically reformat your files before committing.
  • My code follows the Terminal.Gui library design guidelines
  • I ran dotnet test before commit
  • I have made corresponding changes to the API documentation (using /// style comments)
  • My changes generate no new warnings
  • I have checked my code and corrected any poor grammar or misspellings
  • I conducted basic QA to assure all features are working

@BDisp
BDisp requested a review from tig as a code owner April 7, 2026 00:29

@tig tig left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this. I noticed something odd the other day with the ansi driver in this regard and immediately forgot about it because I needed to use the windows driver to test something else and never switched back.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes kitty keyboard protocol handling so shifted printable CSI u keys and kitty “associated text” are preserved and normalized into printable Key semantics, improving text-entry behavior across views.

Changes:

  • Request kitty ReportAssociatedText and parse associated-text payloads in KittyKeyboardPattern.
  • Normalize shifted-printable kitty sequences so keys like Shift+2 resolve to '@' (not base key + Shift).
  • Add/update unit tests across keyboard parsing, Key printable resolution, and text-entry views.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Terminal.Gui/Input/Keyboard/Key.cs Adds AssociatedText, updates printable resolution (AsRune), and introduces GetPrintableText/TryGetPrintableRune.
Terminal.Gui/Drivers/AnsiHandling/KittyKeyboardPattern.cs Extends kitty CSI u parsing to extract associated text and normalizes shifted printable keys.
Terminal.Gui/Drivers/AnsiHandling/EscSeqUtils/EscSeqUtils.cs Requests kitty ReportAssociatedText in the negotiated flags.
Tests/UnitTestsParallelizable/Input/Keyboard/KeyTests.cs Adds tests for printable-text resolution preference order and multi-rune associated text behavior.
Tests/UnitTestsParallelizable/Drivers/AnsiHandling/KittyKeyboardParsingTests.cs Updates fixtures to coherent US-keyboard examples; adds associated-text parsing and requested-flag assertions.
Tests/UnitTestsParallelizable/Drivers/AnsiHandling/KittyAlternateKeyTests.cs Updates alternate-key fixtures and adds associated-text preservation tests.
Tests/UnitTestsParallelizable/Views/TextFieldTests.cs Adds tests for associated-text insertion and shifted-digit behavior without kitty metadata.
Tests/UnitTestsParallelizable/Views/TextView.InputTests.cs Adds test ensuring associated-text shifted printable inserts expected text.
Tests/UnitTestsParallelizable/Views/TextValidateFieldTests.cs Adds test ensuring associated-text shifted printable is accepted by regex provider.

Comment thread Terminal.Gui/Input/Keyboard/Key.cs Outdated
Comment thread Terminal.Gui/Input/Keyboard/Key.cs
@BDisp
BDisp marked this pull request as draft April 7, 2026 08:51
@BDisp
BDisp marked this pull request as ready for review April 7, 2026 22:58
@tig

tig commented Apr 8, 2026

Copy link
Copy Markdown
Member

Excellent work. Thank you.

@tig
tig merged commit f4764b5 into tui-cs:develop Apr 8, 2026
11 checks passed
@BDisp

BDisp commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

On Windows, I'm only capturing the shift key and nothing else. I tried with WezTerm and Rio. I don't know why this happens. Have you managed to get this working on Windows?

@BDisp
BDisp deleted the v2_4893_kitty-keyboard-shifted-fix branch April 8, 2026 14:06
@tig

tig commented Apr 8, 2026

Copy link
Copy Markdown
Member

On Windows, I'm only capturing the shift key and nothing else. I tried with WezTerm and Rio. I don't know why this happens. Have you managed to get this working on Windows?

Not sure what you mean.

WindowsTerminal_Q8ymWjRpe8

@BDisp

BDisp commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator Author

Which Windows Terminal version you're using?

@tig

tig commented Apr 8, 2026

Copy link
Copy Markdown
Member

Windows Terminal Preview
Version: 1.25.622.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kitty keyboard protocol: shifted printable CSI u keys are delivered as shifted base keys instead of printable text

3 participants