Conversation
…-on-attach is off With clear-on-attach off the client terminal keeps its own scrollback on the primary screen. A full-screen application in a pane, such as less or vim, then scrolls that scrollback away: tmux paints the pane's alternate screen with line feeds on the terminal's primary screen. When the active pane fills the window, is not in a mode, and is in its alternate screen, emit smcup to the client terminal before redrawing and rmcup when the pane leaves it. The application draws on the terminal's alternate screen and the terminal restores its scrollback on exit. - tmux.h: TTY_ALTSCREEN flag recording that a pane put the terminal in its alternate screen. - server-client.c: reconcile the terminal's alternate screen with the pane's in server_client_check_redraw() after the tty is unfrozen and before the redraw. Start the synchronized update before the switch so it and the redraw are one frame; leave the ACS character set first since the terminal saves it with the cursor; redraw everything with server_redraw_client() because the new screen has no status line or overlay. Require both smcup and rmcup so a terminal with one but not the other is never put on a screen it cannot leave. - tty.c: leave the alternate screen in tty_stop_tty() if TTY_ALTSCREEN is set so a detach or suspend does not leave the terminal in it; clear the flag in tty_start_tty(). - tmux.1, options-table.c: describe the behaviour under clear-on-attach. No change when clear-on-attach is on, when the terminal lacks smcup or rmcup, in a split, or for applications that do not use the alternate screen.
ejc3
force-pushed
the
altscreen-upstream
branch
from
September 9, 2026 06:16
f8d1acb to
7726507
Compare
ejc3
marked this pull request as ready for review
September 11, 2026 03:58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
clear-on-attach off, a full-screen program in a pane scrolls the terminal's scrollback away. tmux paints the pane's alternate screen onto the terminal's primary screen with line feeds, so every pagelessshows is scrolled into the terminal's scrollback and stays there afterlessquits. Paging through a file left 140 rows of it in the scrollback.This sends
smcupto the client when the active pane fills the window, is not in a mode, and enters its alternate screen, andrmcupwhen it leaves it. The program then draws on the terminal's alternate screen and the terminal restores the primary screen and scrollback itself on exit: 0 rows, with the output from beforelessintact.The switch is made in
server_client_check_redraw()after the tty is unfrozen, inside the same synchronized update as the redraw that follows, and forces a full redraw since the new screen has no status line. A tty flag,TTY_ALTSCREEN, records it.tty_stop_tty()leaves the alternate screen if the flag is set, so a detach or suspend does not leave the terminal in it, and a reattach while the program is still running enters it again. Bothsmcupandrmcupmust be present, so a terminal with one but not the other is never put on a screen it cannot leave.No change with
clear-on-attach on, in a split, or for programs that do not use the alternate screen. The regress suite gives the same results as the parent commit.