Closed destinytaoer closed 2 months ago
The last line can't be cleared. But when i write the last line with CRLF, it can be cleared.
Hello. From what I gather, reset actually resets the entire terminal (it restarts all the running services dependent on the terminal). However (quoting comment) "reset does bot clear input buffers and does not reset the parser". Clear on the other hand simply clears the buffer, while making the prompt line the first line in the buffer and firing a scroll event, which is why it isn't clearing everything, but rather keeping the last line intact. I hope this helped.
Hello. From what I gather, reset actually resets the entire terminal (it restarts all the running services dependent on the terminal). However (quoting comment) "reset does bot clear input buffers and does not reset the parser". Clear on the other hand simply clears the buffer, while making the prompt line the first line in the buffer and firing a scroll event, which is why it isn't clearing everything, but rather keeping the last line intact. I hope this helped.
I got it. The clear method is like entering clear at a terminal, it just clear historical output, and the first line is considered as the user's input. It's that right?
so when i want to clear all input, just use reset method? other advise?
.reset()
might not be what you want, it effectively reboots the terminal (its like pressing off/on on a device), which can have unwanted side effects like erasing pending input. Normally it is enough to call the VT function DECSTR ('\x1b[!p'
) or RIS ('\x1bc'
).
.reset()
might not be what you want, it effectively reboots the terminal (its like pressing off/on on a device), which can have unwanted side effects like erasing pending input. Normally it is enough to call the VT function DECSTR ('\x1b[!p'
) or RIS ('\x1bc'
).
it seems that reset and RIS are the same
There is a difference - RIS is band-synchronous (postponed until all previous input in the write buffer was handled), while term.reset()
gets executed immediately in JS, thus might cut into any state of the terminal.
But sure DECSTR is most of the time enough.
And if you just want to clear the viewport + scrollback while leaving other terminal states untouched, ED 2 + ED 3 + CUP is your friend ('\x1b[2J\x1b[3J\x1b[H'
);
There is a difference - RIS is band-synchronous (postponed until all previous input in the write buffer was handled), while
term.reset()
gets executed immediately in JS, thus might cut into any state of the terminal. But sure DECSTR is most of the time enough.And if you just want to clear the viewport + scrollback while leaving other terminal states untouched, ED 2 + ED 3 + CUP is your friend (
'\x1b[2J\x1b[3J\x1b[H'
);
Got it, Thank you very much!
Details
Unable to clear terminal using clear(),but reset() can clear the terminal what is the different between clear() and reset()?![temrinal](https://github.com/xtermjs/xterm.js/assets/27852774/2f795d90-1dc7-4f71-afdb-04a1f073c7c3)
Steps to reproduce