Skip to main content

ghostty_render_state_begin_update

Function ghostty_render_state_begin_update 

Source
pub unsafe extern "C" fn ghostty_render_state_begin_update(
    state: RenderState,
    terminal: Terminal,
) -> Type
Expand description

Begin an update of a render state instance from a terminal.

Every begin must be completed with a ghostty_render_state_end_update call before the render state is read.

This two-phase structure exists for callers that synchronize access to the terminal state (e.g. with a lock shared with an IO thread): only this function requires terminal access, so a caller can hold its lock for this call only and then call ghostty_render_state_end_update after releasing it. The end phase exclusively reads and writes memory owned by the render state, so it is safe to call while the terminal is being modified.

Work that doesn’t require terminal access may be deferred to the end phase to keep this call (and therefore lock hold time) as short as possible. Callers must treat the render state as incomplete until ghostty_render_state_end_update is called.

This consumes terminal/screen dirty state in the same way as the internal render state update path.

terminal is NULL, GHOSTTY_OUT_OF_MEMORY if updating the state requires allocation and that allocation fails