formatBytesAllocatedWith method

Uint8List formatBytesAllocatedWith(
  1. VtAllocator allocator
)

Formats the terminal using ghostty_formatter_format_alloc and allocator.

Implementation

Uint8List formatBytesAllocatedWith(VtAllocator allocator) {
  _ensureOpen();
  _terminal._ensureOpen();

  final outPtr = calloc<ffi.Pointer<ffi.Uint8>>();
  final outLen = calloc<ffi.Size>();
  try {
    final result = bindings.ghostty_formatter_format_alloc(
      _handle,
      allocator.pointer,
      outPtr,
      outLen,
    );
    _checkResult(result, 'ghostty_formatter_format_alloc');

    return allocator.copyBytesAndFree(outPtr.value, outLen.value);
  } finally {
    calloc.free(outPtr);
    calloc.free(outLen);
  }
}