Skip to content

Fix origin-mode cursor positioning#6

Merged
tomlm merged 6 commits into
tomlm:mainfrom
jchristn:fix/scroll-region-origin-mode
Jun 21, 2026
Merged

Fix origin-mode cursor positioning#6
tomlm merged 6 commits into
tomlm:mainfrom
jchristn:fix/scroll-region-origin-mode

Conversation

@jchristn

Copy link
Copy Markdown
Contributor

Summary

This fixes DEC origin-mode cursor positioning with scroll regions:

  • DECSTBM / CSI t;b r now moves the cursor to home after setting the scroll region.
  • CUP / HVP (CSI row;col H / f) now treat row coordinates as relative to the scroll region when DECOM / origin mode is enabled.
  • VPA / CSI row d now applies the same origin-mode row translation.
  • enabling/disabling origin mode still homes the cursor, using the top margin when origin mode is enabled.

Why

Terminal UIs that reserve a bottom prompt/status row commonly set a scroll region for the output area and use origin-relative cursor addressing. Without these semantics, content can be written to the wrong absolute rows and preserved into scrollback incorrectly.

This is a core emulator behavior fix only. It intentionally does not include any host-rendering, PTY, ConPTY, or Termrig-specific compatibility shims.

Validation

  • dotnet test src\XTerm.NET.slnx --no-restore
  • Result: 589 passed, 0 failed

The test run still reports the existing compiler warnings about EscapeSequenceParser.Dcs and Terminal.HyperlinkChanged; this PR did not introduce new warnings.

@jchristn jchristn marked this pull request as ready for review June 1, 2026 01:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes DEC origin-mode cursor positioning semantics when a scroll region is active, aligning CUP/HVP, VPA, and DECSTBM behavior with expected VT/xterm semantics and adding regression tests to prevent future regressions.

Changes:

  • Added a shared origin-mode row translation helper and applied it to CUP/HVP and VPA.
  • Updated DECSTBM handling to home the cursor after setting the scroll region, and adjusted origin-mode enable/disable homing behavior.
  • Added regression tests covering origin-relative addressing and cursor homing with scroll regions; added a FIXES.md note describing the behavior.

Reviewed changes

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

File Description
src/XTerm.NET/InputHandler.cs Implements origin-mode row translation and cursor homing changes for scroll regions and origin mode toggles.
src/XTerm.NET.Tests/InputHandlerTests.cs Adds regression tests for origin-relative CUP/HVP, origin-relative VPA, and scroll-region cursor homing.
src/XTerm.NET.Tests/ModeHandlingTests.cs Adds regression test ensuring enabling origin mode homes to the top margin when a scroll region is set.
FIXES.md Documents the behavioral fixes and provides minimal reproductions and validation notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/XTerm.NET/InputHandler.cs
Comment thread FIXES.md Outdated
Comment thread FIXES.md Outdated
Comment thread FIXES.md Outdated
@tomlm tomlm merged commit 098c0c5 into tomlm:main Jun 21, 2026
1 check passed
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.

3 participants