bufferDrawText method

void bufferDrawText(
  1. Pointer<OptimizedBufferHandle> buffer,
  2. String text,
  3. int x,
  4. int y,
  5. Color fg,
  6. Color? bg,
  7. int attributes,
)

Draws UTF-8 text at (x,y) into buffer with fg/bg colors and packed attributes. A null bg is passed as a null pointer (transparent). Throws FFIException on failure.

Implementation

void bufferDrawText(
  Pointer<OptimizedBufferHandle> buffer,
  String text,
  int x,
  int y,
  Color fg,
  Color? bg,
  int attributes,
) {
  _guardAlloc('Failed to draw text', (alloc) {
    final (textPtr, textLen) = _utf8(alloc, text);
    final fgPtr = fg.toNative(alloc);
    final bgPtr = bg?.toNative(alloc) ?? nullptr;

    _generated.bufferDrawText(
      buffer.cast(),
      textPtr,
      textLen,
      x,
      y,
      fgPtr,
      bgPtr,
      attributes,
    );
  });
}