printLine method
Appends text as persistent log line(s) above the rendered view.
Lines are stored in a bounded buffer and composited with the view content on each render.
Implementation
void printLine(String text) {
_initialize();
if (text.isEmpty) return;
final lines = text.replaceAll('\r\n', '\n').split('\n');
for (final line in lines) {
if (line.isEmpty) continue;
if (_options.isInline && _options.uiAnchor == UiAnchor.bottom) {
_inlineLogHistory.add(line);
if (_inlineLogHistory.length > _maxPrintLines) {
_inlineLogHistory.removeAt(0);
}
if (TuiTrace.enabled) {
TuiTrace.event(
'inline.print_line',
tag: TraceTag.render,
fields: <String, Object?>{
'line': line,
'historyLength': _inlineLogHistory.length,
'terminalWidth': terminal.width,
'terminalHeight': terminal.height,
'screenHeight': _screen?.height(),
'needsLogReplay': _inlineNeedsLogReplay,
},
);
}
_ensureSize();
if (_replayInlineLogBandIfNeeded()) {
continue;
}
_printInlineLineAboveBottomUi(line);
continue;
}
_printLines.add(line);
if (_printLines.length > _maxPrintLines) {
_printLines.removeAt(0);
}
}
}