Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@gdamore
Copy link
Owner

@gdamore gdamore commented Dec 9, 2025

This adds support for advanced key reporting modes, borrowed from tcell. This also includes the X term modifyOtherKeys protocol.

Note that win32-input-mode is not tested yet as we don't fully support Windows (no termio implementation for it yet), but that will change soon.

Summary by CodeRabbit

  • Improvements

    • Enhanced keyboard protocol support with automatic detection and configuration for Windows and WezTerm terminals.
    • Better compatibility with modern terminal emulator features and improved keyboard input handling.
  • Bug Fixes

    • Ensure terminal mode toggles are reliably emitted on screen start and stop to prevent stale input state.

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

This adds support for advanced key reporting modes, borrowed from
tcell.  This also includes the X term modifyOtherKeys protocol.

Note that win32-input-mode is not tested yet as we don't fully support
Windows (no termio implementation for it yet), but that will change soon.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 9, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Added two public string fields to Vt for CSI‑U/WezTerm sequences, set them based on TERM/TERM_PROGRAM/Windows detection, and emit the enable sequence at screen start and the disable sequence at screen stop.

Changes

Cohort / File(s) Summary
Terminal keyboard protocol initialization
source/dcell/ttyscreen.d
Added enableCsiU and disableCsiU fields to Vt. Detect TERM/TERM_PROGRAM and Windows environment to assign Windows or WezTerm CSI‑U toggle sequences, clear for legacy terminals. Emit enableCsiU during screen start and disableCsiU during screen stop.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Focus review on source/dcell/ttyscreen.d:
    • Correctness of TERM/TERM_PROGRAM/Windows detection logic
    • Placement/timing of emitted sequences in start/stop flows
    • Ensure empty-string fallback for legacy terminals

Possibly related PRs

Poem

🐰 I nibble keys in WezTerm light,
CSI toggles hum all night,
I enable, then I gracefully cease,
Softly restoring keyboard peace,
A rabbit's hop for terminals bright. 🎹

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: Support kitty and win32-input-mode protocols (fixes #30)' directly and clearly summarizes the main changes: adding support for kitty and win32-input-mode keyboard protocols. The title aligns with the code changes introducing CSI U protocol handling for these terminal types.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eaabf4e and dc16b41.

📒 Files selected for processing (1)
  • source/dcell/ttyscreen.d (5 hunks)

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

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: 1

🧹 Nitpick comments (1)
source/dcell/ttyscreen.d (1)

188-207: Env/legacy handling for advanced key protocols looks sound

The conditional init around Lines 188–207 plus the legacy gating at Lines 208–218 is coherent:

  • On Windows, when TERM is empty or TERM_PROGRAM == "WezTerm", you restrict to win32-input-mode only, which matches the comment about not mixing modes.
  • On non-Windows WezTerm, you switch to pure CSI-U (>1u / <u), avoiding modifyOtherKeys/win32, as per the “WezTerm is unhappy if we ask for other modes” note.
  • Legacy terminals zero out vt.enableCsiU / vt.disableCsiU along with other OSC/DSC features, so old/quirky terms never see these sequences.

This wiring aligns with the existing legacy model and keeps advanced modes opt-out on problematic terminals.

If you want to trim repetition, you could cache auto termProgram = environment.get("TERM_PROGRAM"); once before the version (Windows) block and reuse it, but that’s purely cosmetic.

Also applies to: 208-218

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3f1692 and eaabf4e.

📒 Files selected for processing (1)
  • source/dcell/ttyscreen.d (5 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: gdamore
Repo: gdamore/dcell PR: 27
File: source/dcell/ttyscreen.d:164-171
Timestamp: 2025-12-08T19:16:26.974Z
Learning: VT series terminals (vt100, vt102, vt220, vt320, vt420) are strictly monochrome. There are no color terminals with names like "vt220-color" in the VT series. The vt525 is mythical and would use "ansi" for $TERM if needed. Therefore, checking term.startsWith("vt") for monochrome classification is correct.
Learnt from: gdamore
Repo: gdamore/dcell PR: 27
File: source/dcell/ttyscreen.d:763-766
Timestamp: 2025-12-08T19:10:45.974Z
Learning: In source/dcell/ttyscreen.d, the newTtyScreen() factory function intentionally does not accept a term parameter because the TtyScreen constructor handles environment variable resolution internally with an optional term parameter. Users needing to override the terminal type should call the constructor directly: new TtyScreen(newDevTty(), "custom-term").
📚 Learning: 2025-12-08T19:10:45.974Z
Learnt from: gdamore
Repo: gdamore/dcell PR: 27
File: source/dcell/ttyscreen.d:763-766
Timestamp: 2025-12-08T19:10:45.974Z
Learning: In source/dcell/ttyscreen.d, the newTtyScreen() factory function intentionally does not accept a term parameter because the TtyScreen constructor handles environment variable resolution internally with an optional term parameter. Users needing to override the terminal type should call the constructor directly: new TtyScreen(newDevTty(), "custom-term").

Applied to files:

  • source/dcell/ttyscreen.d
📚 Learning: 2025-12-08T19:17:33.657Z
Learnt from: gdamore
Repo: gdamore/dcell PR: 27
File: source/dcell/ttyscreen.d:448-494
Timestamp: 2025-12-08T19:17:33.657Z
Learning: In source/dcell/ttyscreen.d, Color.reset is defined as a value above the range of valid colors. In the sendColors() function, after emitting the reset sequence (vt.resetFgBg), Color.reset values naturally skip all subsequent color-setting logic (isRGB checks and palette range checks < 8, < 256) because they are out of range, which is the correct behavior by design.

Applied to files:

  • source/dcell/ttyscreen.d
📚 Learning: 2025-12-08T19:16:26.974Z
Learnt from: gdamore
Repo: gdamore/dcell PR: 27
File: source/dcell/ttyscreen.d:164-171
Timestamp: 2025-12-08T19:16:26.974Z
Learning: VT series terminals (vt100, vt102, vt220, vt320, vt420) are strictly monochrome. There are no color terminals with names like "vt220-color" in the VT series. The vt525 is mythical and would use "ansi" for $TERM if needed. Therefore, checking term.startsWith("vt") for monochrome classification is correct.

Applied to files:

  • source/dcell/ttyscreen.d
🔇 Additional comments (1)
source/dcell/ttyscreen.d (1)

235-235: Start/stop lifecycle for CSI-U modes is symmetric and minimal

Hooking vt.enableCsiU into start() (Line 235) and vt.disableCsiU into stop() (Line 274) keeps the advanced keyboard protocols active only while the screen is running and restores the previous state on teardown. With legacy/empty cases already mapped to "", this is a safe, no-op-on-unsupported-terms change.

Also applies to: 274-274

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@gdamore gdamore merged commit aee6062 into main Dec 9, 2025
2 of 3 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Dec 10, 2025
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.

2 participants