[PR #12561] [MERGED] Enable using the alt buffer in the Terminal #29113

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/12561
Author: @zadjii-msft
Created: 2/23/2022
Status: Merged
Merged: 4/12/2022
Merged by: @DHowett

Base: mainHead: dev/migrie/b/alt-buffer-terminal


📝 Commits (10+)

  • 83466a4 I think this is the conhost half of the changes
  • e94e08c This quite nearly implements everything for the Terminal half
  • dd702c7 Most of the remaining todos, comments
  • 1209fa4 one last comment
  • bf24cdd more comments are always good
  • dff1b94 spel
  • 60d2c2e fix tests
  • 54dc304 Stashing this for now. I think this does the save/restore cursor stuff that we're supposed to do when entering/exiting the alt buffer
  • 57094b7 start writing tests
  • 69d0973 make this test way more elaborate

📊 Changes

37 files changed (+915 additions, -297 deletions)

View changed files

📝 src/buffer/out/textBuffer.cpp (+1 -1)
📝 src/cascadia/TerminalCore/ITerminalApi.hpp (+3 -0)
📝 src/cascadia/TerminalCore/Terminal.cpp (+131 -57)
📝 src/cascadia/TerminalCore/Terminal.hpp (+9 -3)
📝 src/cascadia/TerminalCore/TerminalApi.cpp (+157 -53)
📝 src/cascadia/TerminalCore/TerminalDispatch.cpp (+84 -0)
📝 src/cascadia/TerminalCore/TerminalDispatch.hpp (+22 -0)
📝 src/cascadia/TerminalCore/TerminalSelection.cpp (+29 -29)
📝 src/cascadia/TerminalCore/terminalrenderdata.cpp (+12 -12)
📝 src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp (+358 -42)
📝 src/cascadia/UnitTests_TerminalCore/ScrollTest.cpp (+1 -1)
📝 src/cascadia/UnitTests_TerminalCore/TerminalApiTest.cpp (+20 -20)
📝 src/cascadia/UnitTests_TerminalCore/TerminalBufferTests.cpp (+10 -10)
📝 src/host/VtIo.cpp (+10 -0)
📝 src/host/VtIo.hpp (+2 -0)
📝 src/host/screenInfo.cpp (+19 -0)
📝 src/interactivity/onecore/BgfxEngine.cpp (+0 -6)
📝 src/interactivity/onecore/BgfxEngine.hpp (+0 -1)
📝 src/renderer/atlas/AtlasEngine.api.cpp (+1 -1)
📝 src/renderer/atlas/AtlasEngine.h (+1 -1)

...and 17 more files

📄 Description

This PR allows the Terminal to actually use the alt buffer
appropriately. Currently, we just render the alt buffer state into the
main buffer and that is wild. It means things like vim will let the
user scroll up to see the previous history (which it shouldn't).

Very first thing this PR does: updates the
{Trigger|Invalidate}Circling methods to instead be
{Trigger|Invalidate}Flush(bool circling). We need this so that when an
app requests the alt buffer in conpty, we can immediately flush the
frame before asking the Terminal side to switch to the other buffer. The
Circling methods was a great place to do this, but we don't actually
want to set the circled flag in VtRenderer when that happens just for a
flush.

The Terminal's implementation is a little different than conhost's.
Conhost's implementation grew organically, so I had it straight up
create an entire new screen buffer for the alt buffer. The Terminal
doesn't need all that! All we need to do is have a separate TextBuffer
for the alt buffer contents. This makes other parts easier as well - we
don't really need to do anything with the _mutableViewport in the alt
buffer, because it's always in the same place. So, we can just leave it
alone and when we come back to the main buffer, there it is. Helper
methods have been updated to account for this.


🔄 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/12561 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 2/23/2022 **Status:** ✅ Merged **Merged:** 4/12/2022 **Merged by:** [@DHowett](https://github.com/DHowett) **Base:** `main` ← **Head:** `dev/migrie/b/alt-buffer-terminal` --- ### 📝 Commits (10+) - [`83466a4`](https://github.com/microsoft/terminal/commit/83466a4381f897e18a822ddc084ddd7d44872669) I think this is the conhost half of the changes - [`e94e08c`](https://github.com/microsoft/terminal/commit/e94e08c303cd60d86919426105ca3c81e2744221) This quite nearly implements everything for the Terminal half - [`dd702c7`](https://github.com/microsoft/terminal/commit/dd702c769dab6ae261e971ee76ac0530f5a60416) Most of the remaining todos, comments - [`1209fa4`](https://github.com/microsoft/terminal/commit/1209fa40c307be9d3856a8f7440ee654361e613d) one last comment - [`bf24cdd`](https://github.com/microsoft/terminal/commit/bf24cdd4b05091e151b2474f73390438c8f0c96c) more comments are always good - [`dff1b94`](https://github.com/microsoft/terminal/commit/dff1b94016651324ad0a50f9bd32b27369deb684) spel - [`60d2c2e`](https://github.com/microsoft/terminal/commit/60d2c2e26dbfc9497fbb7f03045b3dc93123046a) fix tests - [`54dc304`](https://github.com/microsoft/terminal/commit/54dc30411c3c429308a15c7683e748fe3132b30d) Stashing this for now. I think this does the save/restore cursor stuff that we're supposed to do when entering/exiting the alt buffer - [`57094b7`](https://github.com/microsoft/terminal/commit/57094b7d98bad2e7c690692f2b03afc3a968ef01) start writing tests - [`69d0973`](https://github.com/microsoft/terminal/commit/69d0973f1479291d3e5d0ae0dc7c158bf85c966d) make this test way more elaborate ### 📊 Changes **37 files changed** (+915 additions, -297 deletions) <details> <summary>View changed files</summary> 📝 `src/buffer/out/textBuffer.cpp` (+1 -1) 📝 `src/cascadia/TerminalCore/ITerminalApi.hpp` (+3 -0) 📝 `src/cascadia/TerminalCore/Terminal.cpp` (+131 -57) 📝 `src/cascadia/TerminalCore/Terminal.hpp` (+9 -3) 📝 `src/cascadia/TerminalCore/TerminalApi.cpp` (+157 -53) 📝 `src/cascadia/TerminalCore/TerminalDispatch.cpp` (+84 -0) 📝 `src/cascadia/TerminalCore/TerminalDispatch.hpp` (+22 -0) 📝 `src/cascadia/TerminalCore/TerminalSelection.cpp` (+29 -29) 📝 `src/cascadia/TerminalCore/terminalrenderdata.cpp` (+12 -12) 📝 `src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp` (+358 -42) 📝 `src/cascadia/UnitTests_TerminalCore/ScrollTest.cpp` (+1 -1) 📝 `src/cascadia/UnitTests_TerminalCore/TerminalApiTest.cpp` (+20 -20) 📝 `src/cascadia/UnitTests_TerminalCore/TerminalBufferTests.cpp` (+10 -10) 📝 `src/host/VtIo.cpp` (+10 -0) 📝 `src/host/VtIo.hpp` (+2 -0) 📝 `src/host/screenInfo.cpp` (+19 -0) 📝 `src/interactivity/onecore/BgfxEngine.cpp` (+0 -6) 📝 `src/interactivity/onecore/BgfxEngine.hpp` (+0 -1) 📝 `src/renderer/atlas/AtlasEngine.api.cpp` (+1 -1) 📝 `src/renderer/atlas/AtlasEngine.h` (+1 -1) _...and 17 more files_ </details> ### 📄 Description This PR allows the Terminal to actually use the alt buffer appropriately. Currently, we just render the alt buffer state into the main buffer and that is wild. It means things like `vim` will let the user scroll up to see the previous history (which it shouldn't). Very first thing this PR does: updates the `{Trigger|Invalidate}Circling` methods to instead be `{Trigger|Invalidate}Flush(bool circling)`. We need this so that when an app requests the alt buffer in conpty, we can immediately flush the frame before asking the Terminal side to switch to the other buffer. The `Circling` methods was a great place to do this, but we don't actually want to set the circled flag in VtRenderer when that happens just for a flush. The Terminal's implementation is a little different than conhost's. Conhost's implementation grew organically, so I had it straight up create an entire new screen buffer for the alt buffer. The Terminal doesn't need all that! All we need to do is have a separate `TextBuffer` for the alt buffer contents. This makes other parts easier as well - we don't really need to do anything with the `_mutableViewport` in the alt buffer, because it's always in the same place. So, we can just leave it alone and when we come back to the main buffer, there it is. Helper methods have been updated to account for this. * [x] Closes #381 * [x] Closes #3492 * [x] I work here * [x] Tests would be nice * #3686, #3082, #3321, #3493 are all good follow-ups here. --- <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:32:53 +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#29113