[BRLTTY] Was: Re: Linux console hacking > scroll back buffer
Aura Kelloniemi
kaura.dev at sange.fi
Thu May 22 18:54:37 UTC 2025
Hi,
On 2025-05-22 at 14:22 -0400, Dave Mielke <Dave at mielke.cc> wrote:
> [quoted lines by Aura Kelloniemi on 2025/05/22 at 20:20 +0300]
> >But implementing alternate screen
> I find myself wondering what you're referring to. Are you sure you aren't thinking of shell job control (i.e. where you press Ctrl-Z to temporarily suspend the TUI in order to run shell commands)?
Yes, pretty sure.
Alternate screen is an alternative terminal buffer which can be activated and
deactivated using an escape sequence.
Terminals either display contents of the main screen (usually shell and other
command-line tools) or alternative screen (usually full-screen programs). When
a full-screen program, (like less, emacs or vim) starts, it activates the
alternate screen. It then draws its interface to this display buffer. Once the
program exits (or suspends), it returns the main screen, thereby also
restoring the terminal contents to the exact same point where they were before
the program started.
To activate the alternative screen, send "\033[?1049h" to the terminal. To
exit back to main screen, send "\033[?1049l".
The alternate screen mode only affects what is displayed to the user, it does
not affect input mode, flow control or any other terminal state. The alternate
screen has its own scrollback buffer independent of the main screen (or it
does not have scrollback at all, like in tmux).
GNU screen does not have alternate screen support enabled by default, you need
to run the ":altscreen on" command. Tmux enables alternate screen by default.
To try this:
1) Use a relatively modern terminal emulator (if you are in Linux console,
launch tmux)
2) Run a full-screen application, like less (viewing a file)
3) Quit the application
The contents of the application are gone and you see the same shell session
where you started the full-screen program.
You can also use "echo -ne" (with the escape sequences above) to try to
activate/deactivate the alternate screen manually.
--
Aura
More information about the BRLTTY
mailing list