When you open vim or manpage you can't scroll up and check your previous commands, you just stay in this isolated display.
How does this magic work? How to implement it with python?
Or at least say how this thingy is called so I google it properly.
When you open vim or manpage you can't scroll up and check your previous commands, you just stay in this isolated display.
How does this magic work? How to implement it with python?
Or at least say how this thingy is called so I google it properly.
That is called The Alternate Screen Buffer. The terminal emulator provides two modes: primary and alternate; the latter has no scroll back, and when you switch between these buffers the contents in them is preserved. The smcup and rmcup ANSI Escape Sequences are used for switching.
For example, the following displays a FOOBAR banner text for three seconds in the alternate buffer, then switches back to the primary one:
$ tput smcup; banner foobar; sleep 3s; tput rmcup
In Python, you could print the corresponding escape sequences on application start and exit; there may even be a library that does that for you.