clear method
void
clear()
Clears only the lines we wrote by moving cursor up and erasing. This preserves terminal content from before the prompt/view started. Call this before re-rendering to update the display.
Implementation
void clear() {
if (_lineCount > 0) {
// Move cursor up by the number of lines we wrote
TerminalContext.output.write('\x1B[${_lineCount}A');
// Clear from cursor to end of screen (only our content)
TerminalContext.output.write('\x1B[0J');
}
_lineCount = 0;
}