dispose method
Disposes of renderer resources.
Implementation
@override
void dispose() {
// Release transient frame storage. Logical print history is different:
// both log queues are bounded by _maxPrintLines and survive same-instance
// terminal release/restore so user-visible logs are not lost.
_pendingView = '';
_dirty = false;
_inlineCapture.clear();
_fullscreenCapture.clear();
_inlineSink = null;
_inlineNeedsFullClear = false;
// The inline log history is persistent across renderer teardown. A
// dispose clears the visible region, so a same-instance reinitialization
// (used by terminal release/restore) must replay that history on its first
// frame rather than treating it as already present.
_inlineNeedsLogReplay =
_options.isInline && _options.uiAnchor == UiAnchor.bottom;
if (!_initialized) return;
final isInline = _options.isInline;
final isBounded = _options.isBounded;
if (!isBounded) {
terminal.write(uv_graphics.deleteAllRetainedGraphics());
_lastGraphicsFrame = uv_graphics.TerminalGraphicsFrame.empty;
} else {
terminal.write(Ansi.resetScrollRegion);
if (terminal.supportsAnsi) {
_clearInlineRegion();
}
if (isInline && _options.uiAnchor == UiAnchor.bottom) {
terminal.write(Ansi.cursorTo(terminal.height, 1));
}
}
if (_options.hideCursor) {
terminal.showCursor();
}
if (!isBounded && _options.altScreen) {
terminal.exitAltScreen();
}
_renderer?.dispose();
_renderer = null;
_screen?.dispose();
_screen = null;
_nativeFrameCache = null;
_nativeDeltaCache = null;
_nativeCellDeltaCache = null;
_previousNativeFrameForCellDelta = null;
_initialized = false;
}