Struggling to get using xtermjs, and have some questions which aren't covered in the official documentation, at least I didn't find.
CSI ? Pm h
with parameter 47
according to documentation:DECSET DEC Private Set Mode CSI ? Pm h Set various terminal attributes.
Where
paramAction
47 - Use Alternate Screen Buffer.
terminal.write(...)
?Yes, see description here in this question Using the “alternate screen” in a bash script
The alternate screen is used by many "user-interactive" terminal applications like vim, htop, screen, alsamixer, less, ... It is like a different buffer of the terminal content, which disappears when the application exits, so the whole terminal gets restored and it looks like the application hasn't output anything
Yes, ANSI escape code
ANSI escape sequences are a standard for in-band signaling to control the cursor location, color, and other options on video text terminals and terminal emulators. Certain sequences of bytes, most starting with Esc (ASCII character 27) and '[', are embedded into the text, which the terminal looks for and interprets as commands, not as character codes.
CSI ? 47 h
CSI ? 47 l
Code to apply control sequence to switch to alternate buffer:
terminal.write("\x9B?47h"); //CSI ? 47 h