Skip to content

fix: Convert text keypad keys from their CSI-u codes to their text va…#982

Merged
gdamore merged 1 commit intomainfrom
numkeypad
Jan 9, 2026
Merged

fix: Convert text keypad keys from their CSI-u codes to their text va…#982
gdamore merged 1 commit intomainfrom
numkeypad

Conversation

@gdamore
Copy link
Owner

@gdamore gdamore commented Jan 8, 2026

…lues (fixes #981)

Summary by CodeRabbit

  • Refactor

    • Improved keyboard handling to recognize extended key sequences and associated characters more reliably (better support for keypad and extended keys).
  • Chores

    • Updated internal key mapping structures for clearer representation and easier future enhancements.

Note: No public APIs or user-facing interfaces were changed.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 8, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Modified internal key mapping to store both a Key and its Rune. Converted csiUKeys from map[int]Key to map[int]keyMap and updated CSI-u handling to read k1.Key and k1.Rune so keypad CSI-u sequences can yield distinct Key and Rune values.

Changes

Cohort / File(s) Summary
CSI-u keypad key mapping enhancement
input.go
Added Rune rune to keyMap; changed csiUKeys from map[int]Key to map[int]keyMap; updated CSI-u handling sites to use k1.Key and k1.Rune (assigning key = k1.Key, chr = k1.Rune) and populated Rune values for text-keypad entries.

Sequence Diagram(s)

(omitted — changes are internal mapping adjustments without multi-component sequential flow)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 I found a key, then found its rune,
I paired them up beneath the moon.
No mystery codes left in the night,
Texts now hop out clear and bright,
Hooray — the keypad's singing soon!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title refers to converting text keypad keys from CSI-u codes to text values, which is the core objective of the PR.
Linked Issues check ✅ Passed The PR addresses issue #981's requirements by translating keypad private-area codes to ASCII text values and mapping keypad Enter to KeyEnter.
Out of Scope Changes check ✅ Passed All changes are focused on implementing the keypad translation logic; no unrelated modifications are present outside the scope of issue #981.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ccc0943 and f25ad00.

📒 Files selected for processing (1)
  • input.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.69%. Comparing base (83a1490) to head (ccc0943).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #982   +/-   ##
=======================================
  Coverage   81.69%   81.69%           
=======================================
  Files          38       38           
  Lines        3922     3922           
=======================================
  Hits         3204     3204           
  Misses        575      575           
  Partials      143      143           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @input.go:
- Line 345: Fix the incorrect inline comments in the keycode map: for the entry
with key 57415 (currently "57415: {Key: KeyRune, Rune: '='}, // KP_EQUAL        
// KP_ENTER") remove the stray "// KP_ENTER" so it only reads KP_EQUAL, and for
the entry with key 57424 (comment currently "// KP_HOME") change the comment to
"// KP_END" to match the 57424 keycode; update only the comment text next to the
existing map entries (no code logic changes).
- Line 341: The map entry for KP_MULTIPLY is incorrectly using the divide rune;
locate the entry "57411: {Key: KeyRune, Rune: '/'}, // KP_MULTIPLY" and change
the Rune from '/' to '*' so KP_MULTIPLY maps to '*' (ensure KP_DIVIDE remains
'/' and no other keypad mappings are accidentally swapped).
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 83a1490 and b8fb15b.

📒 Files selected for processing (1)
  • input.go
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-06T15:44:36.396Z
Learnt from: gdamore
Repo: gdamore/tcell PR: 977
File: vt/emulate.go:150-150
Timestamp: 2026-01-06T15:44:36.396Z
Learning: In vt/emulate.go for DEC Private Mode 2 (PmVT52), the VT200/VT52 semantics are inverted: when the mode is OFF, VT52 mode is enabled; when the mode is ON, VT52 is disabled and VT100/ANSI mode is active. Ensure reviews verify that ModeOnLocked correctly enforces VT100/ANSI (VT52 disabled) when set, and that enabling OFF path activates VT52 mode. Document this inversion in code comments and tests, and avoid assuming a direct one-way mapping between PmVT52 and VT52 state. If any code branches rely on the opposite behavior, adjust tests accordingly.

Applied to files:

  • input.go
🧬 Code graph analysis (1)
input.go (1)
key.go (44)
  • Key (325-325)
  • ModMask (305-305)
  • KeyESC (497-497)
  • KeyEnter (511-511)
  • KeyBS (478-478)
  • KeyCapsLock (420-420)
  • KeyScrollLock (421-421)
  • KeyNumLock (422-422)
  • KeyPrint (352-352)
  • KeyPause (353-353)
  • KeyMenu (419-419)
  • KeyF13 (367-367)
  • KeyF14 (368-368)
  • KeyF15 (369-369)
  • KeyF16 (370-370)
  • KeyF17 (371-371)
  • KeyF18 (372-372)
  • KeyF19 (373-373)
  • KeyF20 (374-374)
  • KeyF21 (375-375)
  • KeyF22 (376-376)
  • KeyF23 (377-377)
  • KeyF24 (378-378)
  • KeyF25 (379-379)
  • KeyF26 (380-380)
  • KeyF27 (381-381)
  • KeyF28 (382-382)
  • KeyF29 (383-383)
  • KeyF30 (384-384)
  • KeyF31 (385-385)
  • KeyF32 (386-386)
  • KeyF33 (387-387)
  • KeyF34 (388-388)
  • KeyF35 (389-389)
  • KeyRune (332-332)
  • KeyLeft (336-336)
  • KeyRight (335-335)
  • KeyUp (333-333)
  • KeyPgUp (342-342)
  • KeyPgDn (343-343)
  • KeyHome (344-344)
  • KeyEnd (345-345)
  • KeyInsert (346-346)
  • KeyDelete (347-347)
🔇 Additional comments (2)
input.go (2)

136-140: LGTM!

The addition of the Rune field to the internal keyMap struct cleanly enables storing both the key type and its character representation for CSI-u keypad mappings.


1002-1016: LGTM!

The updated logic correctly extracts both Key and Rune from the new keyMap structure. The conditional handling properly distinguishes between:

  • Special keys (e.g., KeyEnter) where key != KeyRune
  • Text keypad keys where key == KeyRune and chr contains the ASCII character

This achieves the PR objective of translating CSI-u private-area codes to their text equivalents.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
input.go (1)

357-357: Clarify the commented-out KeyBegin entry.

The commented-out entry for KeyBegin (code 57427) could benefit from a brief comment explaining why it's disabled—whether KeyBegin is not yet defined in the codebase, not supported, or reserved for future use.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8fb15b and ccc0943.

📒 Files selected for processing (1)
  • input.go
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-06T15:44:36.396Z
Learnt from: gdamore
Repo: gdamore/tcell PR: 977
File: vt/emulate.go:150-150
Timestamp: 2026-01-06T15:44:36.396Z
Learning: In vt/emulate.go for DEC Private Mode 2 (PmVT52), the VT200/VT52 semantics are inverted: when the mode is OFF, VT52 mode is enabled; when the mode is ON, VT52 is disabled and VT100/ANSI mode is active. Ensure reviews verify that ModeOnLocked correctly enforces VT100/ANSI (VT52 disabled) when set, and that enabling OFF path activates VT52 mode. Document this inversion in code comments and tests, and avoid assuming a direct one-way mapping between PmVT52 and VT52 state. If any code branches rely on the opposite behavior, adjust tests accordingly.

Applied to files:

  • input.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
input.go (3)

136-140: LGTM! Clean extension of keyMap struct.

The addition of the Rune field to keyMap provides a flexible way to store both Key identifiers and their character representations, enabling the CSI-u keypad translation without disrupting existing mappings in csiAllKeys.


1002-1004: LGTM! Correct extraction of Key and Rune from keyMap.

The code properly extracts both Key and Rune from the csiUKeys entries, enabling the downstream logic (lines 1011-1015) to correctly distinguish between functional keys (posting key events without strings) and text keypad keys (posting rune events with ASCII characters). This implements the PR objective of translating keypad CSI-u codes to their text values.


295-360: The keypad private-area code mappings are correct and match the Kitty keyboard protocol specification.

All codes (57399–57426) have been verified against the official Kitty keyboard protocol. The implementation correctly maps keypad keys to their respective Private Use Area codepoints:

  • Keypad digits (57399–57408) and operators (57409–57416) properly use KeyRune with corresponding ASCII values.
  • Navigation and function keys (57417–57426) properly map to specific Key constants.
  • The commented-out KP_BEGIN (57427) is a valid entry but may not yet be supported.

@gdamore gdamore merged commit f25ad00 into main Jan 9, 2026
11 of 12 checks passed
@gdamore gdamore deleted the numkeypad branch January 9, 2026 06:46
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.

Convert text keypad keys from their CSI-u codes to their text values

1 participant