vt: add size getter for render state

Add ghostty_render_state_size_get() to return cols and rows from the
current render state using out pointers. The C wrapper validates null
inputs, the symbol is wired through the C API export layers, and tests
cover success and invalid-value paths.
This commit is contained in:
Mitchell Hashimoto
2026-03-18 12:22:32 -07:00
parent 2876fb7a55
commit b830a0ee1d
4 changed files with 72 additions and 0 deletions

View File

@@ -95,6 +95,24 @@ GhosttyResult ghostty_render_state_new(const GhosttyAllocator* allocator,
GhosttyResult ghostty_render_state_update(GhosttyRenderState state,
GhosttyTerminal terminal);
/**
* Get the current viewport size from a render state.
*
* The returned values are the render-state dimensions in cells. These
* match the active viewport size from the most recent successful update.
*
* @param state The render state handle (NULL returns GHOSTTY_INVALID_VALUE)
* @param[out] out_cols On success, receives the viewport width in cells
* @param[out] out_rows On success, receives the viewport height in cells
* @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if `state`,
* `out_cols`, or `out_rows` is NULL
*
* @ingroup render
*/
GhosttyResult ghostty_render_state_size_get(GhosttyRenderState state,
uint16_t* out_cols,
uint16_t* out_rows);
/**
* Get the current dirty state of a render state.
*