Reputation: 6732
I want to take over the console like less does, to make a more interactive app. It seems like they have complete control over what gets drawn where. How can I do that?
Upvotes: 1
Views: 206
Reputation: 8532
Primarily, less
and other full-screen terminal applications use the alternate screen mode; otherwise known as DEC mode 1049. terminfo
stores the strings needed to enter/exit this mode in
enter_ca_mode=\E[?1049h
exit_ca_mode=\E[?1049l
Once you enter alternate screen mode, you get full control of the screen by the usual escape sequences, drawing to an entirely separate "buffer" on most terminals, that leaves the regular buffer (such as may contain the bash scrollback) unaffected. When you leave alternate screen mode again it restores the previous contents and cursor state.
Upvotes: 1
Reputation: 5414
The ANSI escape codes might be a place to start. http://en.wikipedia.org/wiki/ANSI_escape_code
Upvotes: 0