Rendering and Display
The libghostty rendering API provides functions for managing terminal surface rendering, sizing, and display properties.Surface Management
ghostty_surface_new
Creates a new terminal surface.ghostty_app_t
required
The app instance that will own this surface.
const ghostty_surface_config_s*
required
Configuration for the new surface.
ghostty_surface_free
Frees a surface and its resources.ghostty_surface_t
required
The surface to free.
ghostty_surface_config_new
Creates a default surface configuration.ghostty_surface_inherited_config
Gets configuration for creating a derived surface (e.g., split).ghostty_surface_t
required
The parent surface.
ghostty_surface_context_e
required
The context for the new surface (tab, split, etc.).
Rendering
ghostty_surface_draw
Draws the surface to its render target.ghostty_surface_t
required
The surface to draw.
ghostty_surface_refresh
Marks the surface as needing a redraw.ghostty_surface_t
required
The surface to refresh.
Size and Scale
ghostty_surface_set_size
Sets the surface size in pixels.ghostty_surface_t
required
The surface to resize.
uint32_t
required
New width in pixels.
uint32_t
required
New height in pixels.
ghostty_surface_size
Gets the current surface size.ghostty_surface_t
required
The surface to query.
ghostty_surface_set_content_scale
Sets the content scale factor (for high-DPI displays).ghostty_surface_t
required
The surface.
double
required
Horizontal scale factor (e.g., 2.0 for Retina).
double
required
Vertical scale factor.
Focus and Occlusion
ghostty_surface_set_focus
Sets the focus state of the surface.ghostty_surface_t
required
The surface.
bool
required
Whether the surface has focus.
ghostty_surface_set_occlusion
Sets whether the surface is occluded (hidden by other windows).ghostty_surface_t
required
The surface.
bool
required
Whether the surface is occluded.
ghostty_surface_set_color_scheme
Sets the color scheme preference.ghostty_surface_t
required
The surface.
ghostty_color_scheme_e
required
Color scheme (light or dark).
Configuration
ghostty_surface_update_config
Updates the surface configuration.ghostty_surface_t
required
The surface to update.
ghostty_config_t
required
New configuration to apply.
Surface Queries
ghostty_surface_userdata
Gets the user data pointer associated with the surface.ghostty_surface_t
required
The surface.
ghostty_surface_config_s.
ghostty_surface_app
Gets the app that owns the surface.ghostty_surface_t
required
The surface.
ghostty_surface_needs_confirm_quit
Checks if the surface needs confirmation before closing.true if there’s a running process that would be terminated.
ghostty_surface_process_exited
Checks if the surface’s shell process has exited.true if the process has exited.
Platform-Specific (macOS)
- macOS
Text Selection
ghostty_surface_has_selection
Checks if the surface has an active selection.true if text is selected.
ghostty_surface_read_selection
Reads the currently selected text.ghostty_surface_t
required
The surface.
ghostty_text_s*
required
Pointer to store the selected text.
true if text was read successfully.
Must free with ghostty_surface_free_text().
ghostty_surface_read_text
Reads text from a specific region.ghostty_surface_t
required
The surface.
ghostty_selection_s
required
The region to read.
ghostty_text_s*
required
Pointer to store the text.
true if text was read successfully.
ghostty_surface_free_text
Frees text returned by read functions.Surface Actions
ghostty_surface_binding_action
Executes a binding action by name.ghostty_surface_t
required
The surface.
const char*
required
Action name.
uintptr_t
required
Length of action string.
true if the action was executed.
Example:
ghostty_surface_request_close
Requests the surface to close.ghostty_surface_t
required
The surface to close.
close_surface_cb callback.
Split Management
ghostty_surface_split
Splits the surface in a direction.ghostty_surface_t
required
The surface to split.
ghostty_action_split_direction_e
required
Split direction (right, down, left, up).
ghostty_surface_split_focus
Moves focus to an adjacent split.ghostty_surface_split_resize
Resizes a split pane.ghostty_surface_split_equalize
Equalizes split pane sizes.Complete Rendering Example
See Also
- Core Types - Surface configuration types
- Input Handling - Handling user input
- Embedding Guide - Complete embedding tutorial