vt: expose dirty state in C API

Switch RenderState.Dirty to lib.Enum so it uses C-compatible enum
backing when building the C ABI target. Add GhosttyRenderStateDirty and
new ghostty_render_state_dirty_get/set declarations to the render header,
then wire both functions through src/terminal/c/main.zig and the lib_vt
export table.
This commit is contained in:
Mitchell Hashimoto
2026-03-18 09:54:03 -07:00
parent a0d738697e
commit 2876fb7a55
5 changed files with 140 additions and 12 deletions

View File

@@ -49,6 +49,22 @@ extern "C" {
*/
typedef struct GhosttyRenderState* GhosttyRenderState;
/**
* Dirty state of a render state after update.
*
* @ingroup render
*/
typedef enum {
/** Not dirty at all; rendering can be skipped. */
GHOSTTY_RENDER_STATE_DIRTY_FALSE = 0,
/** Some rows changed; renderer can redraw incrementally. */
GHOSTTY_RENDER_STATE_DIRTY_PARTIAL = 1,
/** Global state changed; renderer should redraw everything. */
GHOSTTY_RENDER_STATE_DIRTY_FULL = 2,
} GhosttyRenderStateDirty;
/**
* Create a new render state instance.
*
@@ -79,6 +95,34 @@ GhosttyResult ghostty_render_state_new(const GhosttyAllocator* allocator,
GhosttyResult ghostty_render_state_update(GhosttyRenderState state,
GhosttyTerminal terminal);
/**
* Get the current dirty state of a render state.
*
* @param state The render state handle (NULL returns GHOSTTY_INVALID_VALUE)
* @param[out] out_dirty On success, receives the current dirty state
* @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if `state` is
* NULL
*
* @ingroup render
*/
GhosttyResult ghostty_render_state_dirty_get(GhosttyRenderState state,
GhosttyRenderStateDirty* out_dirty);
/**
* Set the dirty state of a render state.
*
* This can be used by callers to clear dirty state after handling updates.
*
* @param state The render state handle (NULL returns GHOSTTY_INVALID_VALUE)
* @param dirty The dirty state to set
* @return GHOSTTY_SUCCESS on success, GHOSTTY_INVALID_VALUE if `state` is
* NULL or `dirty` is not a recognized enum value
*
* @ingroup render
*/
GhosttyResult ghostty_render_state_dirty_set(GhosttyRenderState state,
GhosttyRenderStateDirty dirty);
/**
* Free a render state instance.
*