I'm trying to remove the last line of a xtermjs terminal. In the docs I have only found the clear
and reset
methods, but I just want to remove the last line.
How to remove the last line in xterm.js
I solved this based on the answers of this question
\33[2K erases the entire line your cursor is currently on
\033[A moves your cursor up one line, but in the same column i.e. not to the start of the line
\r brings your cursor to the beginning of the line (r is for rewind) but does not erase anything
I ended up using this to erase the last line:
terminal.write('\x1b[2K\r')
\x1b is the hexadecimal of \033, because I was getting this error when using the octal version.
Octal literal in strict mode
© 2022 - 2024 — McMap. All rights reserved.