VtRowSnapshot.fromRaw constructor

VtRowSnapshot.fromRaw(
  1. DartGhosttyRow row
)

Implementation

factory VtRowSnapshot.fromRaw(bindings.DartGhosttyRow row) {
  bool getBool(bindings.GhosttyRowData data) {
    final out = calloc<ffi.Bool>();
    try {
      _checkResult(
        bindings.ghostty_row_get(row, data, out.cast()),
        'row_get',
      );
      return out.value;
    } finally {
      calloc.free(out);
    }
  }

  final semanticPrompt = calloc<ffi.UnsignedInt>();
  try {
    _checkResult(
      bindings.ghostty_row_get(
        row,
        bindings.GhosttyRowData.GHOSTTY_ROW_DATA_SEMANTIC_PROMPT,
        semanticPrompt.cast(),
      ),
      'row_get',
    );
    return VtRowSnapshot(
      wrap: getBool(bindings.GhosttyRowData.GHOSTTY_ROW_DATA_WRAP),
      wrapContinuation: getBool(
        bindings.GhosttyRowData.GHOSTTY_ROW_DATA_WRAP_CONTINUATION,
      ),
      hasGrapheme: getBool(bindings.GhosttyRowData.GHOSTTY_ROW_DATA_GRAPHEME),
      styled: getBool(bindings.GhosttyRowData.GHOSTTY_ROW_DATA_STYLED),
      hasHyperlink: getBool(
        bindings.GhosttyRowData.GHOSTTY_ROW_DATA_HYPERLINK,
      ),
      semanticPrompt: bindings.GhosttyRowSemanticPrompt.fromValue(
        semanticPrompt.value,
      ),
      kittyVirtualPlaceholder: getBool(
        bindings.GhosttyRowData.GHOSTTY_ROW_DATA_KITTY_VIRTUAL_PLACEHOLDER,
      ),
      dirty: getBool(bindings.GhosttyRowData.GHOSTTY_ROW_DATA_DIRTY),
    );
  } finally {
    calloc.free(semanticPrompt);
  }
}