render method
Renders the view to the terminal.
view is the string representation of the current UI state,
or a View object containing metadata.
Implementation
@override
void render(Object view) {
_metrics.beginFrame();
if (!_initialized) {
initialize();
}
final String content = switch (view) {
String s => s,
View v => v.content,
_ => view.toString(),
};
// Frame rate limiting
if (_lastRenderTime != null) {
final elapsed = DateTime.now().difference(_lastRenderTime!);
if (elapsed < _options.frameTime) {
// Skip this frame
_metrics.endFrame(skipped: true);
return;
}
}
// Skip if view hasn't changed
if (content == _lastView) {
_metrics.endFrame(skipped: true);
return;
}
// Full redraw (future: diff with _lastView and update only changed lines)
terminal.cursorHome();
final output = _options.ansiCompress ? compressAnsi(content) : content;
terminal.write(output);
// Clear any remaining content from previous render
_clearToEndOfScreen(content);
_lastView = content;
_lastRenderTime = DateTime.now();
_metrics.endFrame();
}