-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alternate screen shouldn't write to scrollback or normal screen #3492
Comments
This is actually one of the unfortunate circumstances of the pseudoconsole API. conhost implements the alt buffer reasonably well (we think): it turns off scrollback, reflow, and so on. |
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 * #3686, #3082, #3321, #3493 are all good follow-ups here.
🎉This issue was addressed in #12561, which has now been successfully released as Handy links: |
Environment
Epic
Scrollback handling should be just like in VTE because that's the best (ahem ahem) 🤣
Steps to reproduce 1
ssh
to a Linux box, and execute these:scroll back and examine the contents
Expected behavior 1
Outputs of these two
seq
s shouldn't interleaveActual behavior 1
Output consists of
normal 1
tonormal 74
(exact number depends on the window height), followed byalt 1
toalt 74
, and finallynormal 75
tonormal 100
. (alt 75
onwards are gone.)Steps to reproduce 2
ssh
to a Linux box.mc
mc
Expected behavior 2
This should look okay (see below).
Actual behavior 2
The contents seem quite garbled. Most of the time you'll see remains of
mc
's user interface in the scrollback buffer; sometimes even on the normal screen (this latter is harder to reproduce, and perhaps only happens with solid background colors).VTE rocks
The way this works amazingly in gnome-terminal is:
The alternate screen is pretty much only used by fullscreen apps that control the entire UI and repaint on window resize. Therefore it's unrelated to the normal screen and the scrollback. Data never travels between the (normal screen + scrollback) combo and the alternate screen. The scrollback buffer belongs to the normal screen only. Everything scrolled out from the alternate screen is lost for good.
On resize, the (normal screen + scrollback) is resized as a single unit, for the resizing operation it doesn't matter where the boundary is.
The (normal screen + scrollback) combo is resized the same way, regardless of whether it's the active one or the alternate screen is shown. Stress-test this: produce output on the normal screen, switch to the alternate one (e.g.
mc
), resize, quitmc
. The normal screen's contents will be updated to the new width just as if you haven't switched to the alternate screen.There's plenty of further tiny details to this story, e.g. how to vertically position the contents, some of which are documented in VTE's doc/rewrap.txt.
Of course there's no specification anywhere that all this has to behave like this. It's just what I believe makes the most sense. Obviously my opinion is quite biased since this was my first big contribution to VTE. :) Luckily I only had to do the rewrapping; the separation of the (normal screen + scrollback) vs. alternate screen was already as desired.
The text was updated successfully, but these errors were encountered: