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

Skip to content

Conversation

@gdamore
Copy link
Owner

@gdamore gdamore commented Dec 10, 2025

Summary by CodeRabbit

  • Documentation

    • Clarified that Windows Terminal and other console emulators on Windows are fully supported.
  • Bug Fixes

    • Fixed cursor positioning to use correct coordinate system for terminal output.
    • Improved Windows console key event handling to prevent capturing invalid key states.
    • Corrected window size detection on Windows platforms.
    • Enhanced selection highlighting to properly include all boundary cells.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 10, 2025

Walkthrough

This pull request addresses Windows terminal support and cursor positioning bugs. The README documentation is updated to reflect Windows support. Mouse selection boundaries are corrected to include edge cells. Windows key-event handling is refined to avoid capturing non-press events. Window size retrieval is refactored to use local variable computation. Cursor positioning is changed from 0-based to 1-based output, and WezTerm-specific CSI U mode handling is simplified.

Changes

Cohort / File(s) Summary
Documentation Update
README.md
Updated narrative to state Windows Terminal and other console emulators on Windows are supported, removing the previous "missing" statement.
Mouse Selection Drawing
demos/mouse/source/mouse.d
Modified boundary condition in drawSelect loops to include bottom row and rightmost column (≀ instead of <) for complete rectangle highlighting.
Windows Terminal Input & Window Size
source/dcell/termio.d
Fixed Windows key-event handling to only append characters when key is pressed and char is non-zero; refactored window size retrieval to use local CONSOLE_SCREEN_BUFFER_INFO variable instead of oscreen field, removing unused field.
Cursor Positioning & CSI U Mode
source/dcell/ttyscreen.d
Changed cursor position output from 0-based to 1-based (pos.y+1, pos.x+1); simplified CSI U mode logic to check only for empty term string, removing WezTerm-specific alternate behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas requiring extra attention:
    • Windows console API changes in termio.d (key-event filtering and console buffer info struct usage)
    • Cursor positioning shift from 0-based to 1-based in ttyscreen.d (verify compatibility with all terminal implementations)
    • Mouse boundary condition change in mouse.d (confirm visual impact and no off-by-one regressions)

Possibly related PRs

Poem

🐰 Whiskers twitch at Windows' call,
Cursors leap from row to all,
Boundaries drawn, selection wide,
Keys pressed true, no ghosts to hide,
Terminal dance, now crisp and 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 title 'More fixes for windows, coordination calculation bugs' accurately reflects the main changes: multiple Windows-specific fixes and coordinate/positioning calculation corrections across multiple files.
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
πŸ§ͺ Generate unit tests (beta)

βœ… Unit Test PR creation complete.

  • Create PR with unit tests
  • Commit unit tests in branch gdamore/more-windows
  • Post copyable unit tests in a comment

πŸ“œ 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 192496c and 02b056e.

πŸ“’ Files selected for processing (4)
  • README.md (1 hunks)
  • demos/mouse/source/mouse.d (1 hunks)
  • source/dcell/termio.d (3 hunks)
  • source/dcell/ttyscreen.d (2 hunks)
🧰 Additional context used
🧠 Learnings (3)
πŸ“š 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:

  • README.md
  • source/dcell/ttyscreen.d
  • source/dcell/termio.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 (7)
demos/mouse/source/mouse.d (1)

75-89: LGTM! Selection boundary fix is correct.

The loop conditions now correctly include the boundary cells at c2.y and c2.x, ensuring the entire selected rectangle is highlighted. This aligns with standard selection behavior where both corner coordinates are inclusive.

README.md (1)

13-14: LGTM! Documentation accurately reflects Windows support.

The updated narrative correctly indicates that Windows Terminal and similar console emulators are now supported, aligning with the Windows-specific improvements made in this PR.

source/dcell/ttyscreen.d (2)

189-198: LGTM! Simplified Windows terminal mode detection.

The refactored conditional now enables CSI U mode (win32-input-mode only) when the term string is empty, removing the previous WezTerm-specific handling. This simplification aligns with the broader Windows support improvements in this PR.


571-578: LGTM! Critical fix for cursor positioning.

The CSI H sequence (\x1b[row;colH) requires 1-based coordinates per VT standards, but the internal pos coordinate is 0-based (as used for array indexing throughout the code). Adding +1 to both dimensions correctly converts to the required 1-based output format, fixing a cursor positioning bug.

source/dcell/termio.d (3)

422-422: LGTM! Typo fix.

Corrected "stanrdard" to "standard" in the comment.


621-627: LGTM! Improved Windows key event filtering.

The added conditions correctly filter key events to only process actual key presses (bKeyDown) with non-zero ASCII characters. This prevents capturing key release events and keys that don't produce character output, which should be handled through VT sequences instead.


655-661: LGTM! Window size calculation now uses visible window dimensions.

The refactored implementation correctly computes window size from srWindow (the visible console window area) rather than the buffer size. The calculation Right - Left + 1 and Bottom - Top + 1 properly accounts for inclusive coordinates, ensuring accurate window dimensions across Windows console variants.


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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 10, 2025

Note

Unit test generation is an Early Access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

@gdamore gdamore merged commit 1dd5e39 into main Dec 10, 2025
3 checks passed
@gdamore gdamore deleted the gdamore/more-windows branch December 10, 2025 19:21
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 10, 2025

Caution

The CodeRabbit agent's plans did not produce any file changes.

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