How does the man program manage to restore previous terminal output after taking over the entire screen? Does it involve ANSI escape sequences in a way?
Asked
Active
Viewed 47 times
1
-
you can always get the source for `man` and see what it's doing... – Marc B Jul 28 '15 at 20:06
1 Answers
2
That is the ubiquitous xterm alternate-screen feature, which most terminal programs use via the terminfo smcup
and rmcup
sequences. For recent comments on this feature:
- How to Not Overwrite Previous Terminal Contents
- What mechanism allows ViM to temporarily overwrite the entire console?
(By the way, the man
program is usually a "termcap" program).

Community
- 1
- 1

Thomas Dickey
- 51,086
- 7
- 70
- 105
-
Heh. I use a custom terminfo entry with empty `smcup`/`rmcup` fields just so I can stop programs from switching to an alternate screen. I hate it when I quit, say, `less` and the whole text I was looking at is just gone. – melpomene Jul 28 '15 at 21:25