bufferDrawText method

void bufferDrawText(
  1. OptimizedBufferHandle buffer,
  2. String text,
  3. int x,
  4. int y,
  5. Color foreground,
  6. Color? background,
  7. int attributes,
)

Draws one styled UTF-8 run.

Implementation

void bufferDrawText(
  OptimizedBufferHandle buffer,
  String text,
  int x,
  int y,
  Color foreground,
  Color? background,
  int attributes,
) {
  _checkUnsignedAbi(x, 0xFFFFFFFF, 'x');
  _checkUnsignedAbi(y, 0xFFFFFFFF, 'y');
  _checkUnsignedAbi(attributes, 0xFFFFFFFF, 'attributes');
  validateColorChannels(foreground, name: 'foreground');
  if (background != null) {
    validateColorChannels(background, name: 'background');
  }
  _guardAlloc('Failed to draw text', (allocator) {
    final (textPointer, textLength) = _utf8(allocator, text);
    _native.bufferDrawText(
      buffer.value,
      textPointer,
      textLength,
      x,
      y,
      _colorToNative(foreground, allocator),
      background == null ? nullptr : _colorToNative(background, allocator),
      attributes,
    );
  });
}