[PR #10843] [MERGED] Make the alt buffer inherit cursor state from the main buffer #28254

Open
opened 2026-01-31 09:27:20 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/10843
Author: @j4james
Created: 8/1/2021
Status: Merged
Merged: 8/2/2021
Merged by: @undefined

Base: mainHead: fix-alt-state


📝 Commits (5)

  • a062838 Inherit main cursor position in the alt buffer.
  • b5d9341 Inherit main cursor visibility in the alt buffer.
  • 0604d8f Copy alt cursor style and visibility back to main buffer.
  • 75a76b7 Fix test that relied on alt cursor being set to home.
  • 044efd4 Add unit tests confirming alt buffer cursor inheritance.

📊 Changes

2 files changed (+86 additions, -2 deletions)

View changed files

📝 src/host/screenInfo.cpp (+16 -2)
📝 src/host/ut_host/ScreenBufferTests.cpp (+70 -0)

📄 Description

When switching to the alt buffer, the starting cursor position, style,
and visibility is meant to be inherited from the main buffer. Similarly,
when returning to the main buffer, any changes made to those attributes
should be copied back (with the exception of the cursor position, which
is restored to its original state). This PR makes sure we handle that
cursor state correctly.

At some point I'd like to move the cursor state out of the
SCREEN_INFORMATION class, which would make this inheritance problem a
non-issue. For now, though, I've just made it copy the state from the
main buffer when creating the alt buffer, and copy it back when
returning to the main buffer.

Validation Steps Performed

I've added some unit tests to verify the cursor state is inherited
correctly when switching to the alt buffer and back again. I also had to
make a small change to one of the existing alt buffer test that relied
on the initial cursor position being at 0;0, which is no longer the
case.

I've verified that the test case in issue #3545 is now working
correctly. I've also confirmed that this fixes a problem in the
notcurses demo, where the cursor was showing when it should have been
hidden.

Closes #3545


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/10843 **Author:** [@j4james](https://github.com/j4james) **Created:** 8/1/2021 **Status:** ✅ Merged **Merged:** 8/2/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `fix-alt-state` --- ### 📝 Commits (5) - [`a062838`](https://github.com/microsoft/terminal/commit/a062838d69897e4ec9a709e09f0fcad1ec1635e0) Inherit main cursor position in the alt buffer. - [`b5d9341`](https://github.com/microsoft/terminal/commit/b5d93419eaccf36788fb32d440c87949538017f5) Inherit main cursor visibility in the alt buffer. - [`0604d8f`](https://github.com/microsoft/terminal/commit/0604d8fc63494d44154ea9382f80b05288aa491a) Copy alt cursor style and visibility back to main buffer. - [`75a76b7`](https://github.com/microsoft/terminal/commit/75a76b703c58a5427a0673c2264b0009adafa385) Fix test that relied on alt cursor being set to home. - [`044efd4`](https://github.com/microsoft/terminal/commit/044efd4c1d5dacbfd3eeb872bb1d2b21a8cab297) Add unit tests confirming alt buffer cursor inheritance. ### 📊 Changes **2 files changed** (+86 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/host/screenInfo.cpp` (+16 -2) 📝 `src/host/ut_host/ScreenBufferTests.cpp` (+70 -0) </details> ### 📄 Description When switching to the alt buffer, the starting cursor position, style, and visibility is meant to be inherited from the main buffer. Similarly, when returning to the main buffer, any changes made to those attributes should be copied back (with the exception of the cursor position, which is restored to its original state). This PR makes sure we handle that cursor state correctly. At some point I'd like to move the cursor state out of the `SCREEN_INFORMATION` class, which would make this inheritance problem a non-issue. For now, though, I've just made it copy the state from the main buffer when creating the alt buffer, and copy it back when returning to the main buffer. ## Validation Steps Performed I've added some unit tests to verify the cursor state is inherited correctly when switching to the alt buffer and back again. I also had to make a small change to one of the existing alt buffer test that relied on the initial cursor position being at 0;0, which is no longer the case. I've verified that the test case in issue #3545 is now working correctly. I've also confirmed that this fixes a problem in the _notcurses_ demo, where the cursor was showing when it should have been hidden. Closes #3545 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:27:20 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#28254