textBufferWriteChunk method

int textBufferWriteChunk(
  1. Pointer<TextBufferHandle> textBuffer,
  2. String text,
  3. Color fg,
  4. Color bg,
  5. int attributes,
)

Appends UTF-8 text to textBuffer with fg/bg colors and packed attributes, returning the native write result. Throws FFIException on failure.

Implementation

int textBufferWriteChunk(
  Pointer<TextBufferHandle> textBuffer,
  String text,
  Color fg,
  Color bg,
  int attributes,
) => _guardAlloc('Failed to write text buffer chunk', (alloc) {
  final (textPtr, textLen) = _utf8(alloc, text);

  final attrPtr = alloc<Uint8>();
  attrPtr[0] = attributes;

  return _generated.textBufferWriteChunk(
    textBuffer.cast(),
    textPtr,
    textLen,
    fg.toNative(alloc),
    bg.toNative(alloc),
    attrPtr,
  );
});