setLine method

void setLine(
  1. int x,
  2. int y,
  3. Line line,
  4. {int? maxWidth}
)

Sets cells starting at the given x and y coordinates to line.

If maxWidth is provided, the line will be truncated to fit within the buffer's width, which otherwise defaults to the buffer's width if omitted.

Throws if the coordinates are out of bounds.

Implementation

void setLine(int x, int y, Line line, {int? maxWidth}) {
  final width = maxWidth ?? this.width;
  var i = 0;
  for (final span in line.spans) {
    final content = span.content;
    final style = span.style;
    print(
      x + i,
      y,
      content,
      maxWidth: width - x - i,
      style: line.style.overrideWith(style),
    );
    i += content.characters.length;
  }
}