current property
The cell at this cursor's current position.
Implementation
VtRenderCellSnapshot get current {
_ensureOpen();
final raw = calloc<bindings.GhosttyCell>();
final style = calloc<bindings.GhosttyStyle>();
final graphemeLen = calloc<ffi.Uint32>();
try {
style.ref.size = ffi.sizeOf<bindings.GhosttyStyle>();
_checkResult(
bindings.ghostty_render_state_row_cells_get(
_handle,
bindings
.GhosttyRenderStateRowCellsData
.GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_RAW,
raw.cast(),
),
'ghostty_render_state_row_cells_get',
);
_checkResult(
bindings.ghostty_render_state_row_cells_get(
_handle,
bindings
.GhosttyRenderStateRowCellsData
.GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_STYLE,
style.cast(),
),
'ghostty_render_state_row_cells_get',
);
_checkResult(
bindings.ghostty_render_state_row_cells_get(
_handle,
bindings
.GhosttyRenderStateRowCellsData
.GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_GRAPHEMES_LEN,
graphemeLen.cast(),
),
'ghostty_render_state_row_cells_get',
);
final graphemes = graphemeLen.value == 0
? ''
: (() {
final buffer = calloc<ffi.Uint32>(graphemeLen.value);
try {
_checkResult(
bindings.ghostty_render_state_row_cells_get(
_handle,
bindings
.GhosttyRenderStateRowCellsData
.GHOSTTY_RENDER_STATE_ROW_CELLS_DATA_GRAPHEMES_BUF,
buffer.cast(),
),
'ghostty_render_state_row_cells_get',
);
return String.fromCharCodes(
buffer.asTypedList(graphemeLen.value),
);
} finally {
calloc.free(buffer);
}
})();
return VtRenderCellSnapshot(
raw: VtCellSnapshot.fromRaw(raw.value),
style: VtStyle.fromNative(style.ref),
graphemes: graphemes,
);
} finally {
calloc.free(graphemeLen);
calloc.free(style);
calloc.free(raw);
}
}