finishClearingLastLine method

void finishClearingLastLine()

Finishes by clearing only the last rendered line, preserving the lines above it and leaving the cursor at the start of the cleared line.

Subsequent output therefore begins where the last line was. Relies on the cursor being at the end of the last rendered line, which is the case right after a render.

Implementation

void finishClearingLastLine() {
  if (_renderedLineCount > 0) {
    // Move to the start of the (current) last line and clear from there to
    // the end of the screen.
    _terminal.write('\r$_esc[0J');
  }
  showCursor();
  _renderedLineCount = 0;
}