draw method

  1. @override
void draw(
  1. Screen screen,
  2. Rectangle area
)
override

Draws this styled string into screen inside area, clearing first.

Implementation

@override
/// Draws this styled string into [screen] inside [area], clearing first.
void draw(Screen screen, Rectangle area) {
  final clearable = screen is ClearAreaScreen ? screen : null;
  if (clearable == null) {
    // Clear the area before drawing.
    for (var y = area.minY; y < area.maxY; y++) {
      for (var x = area.minX; x < area.maxX; x++) {
        screen.setCell(x, y, null);
      }
    }
  } else {
    clearable.clearArea(area);
  }

  // Normalize CRLF to NL to emulate raw terminal output.
  final normalized = text.contains('\r')
      ? text.replaceAll('\r\n', '\n')
      : text;
  final expanded = term_ansi.Ansi.expandTabs(normalized);

  _printString(
    screen,
    WidthMethod.grapheme,
    area.minX,
    area.minY,
    area,
    expanded,
    truncate: !wrap,
    tail: tail,
  );
}