How to remove the last line in xterm.js
Asked Answered
T

1

5

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.

Teniacide answered 1/7, 2019 at 0:21 Comment(0)
T
13

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

Teniacide answered 1/7, 2019 at 0:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.