Core Types
This page documents the core types and data structures used throughout the libghostty C API.Opaque Types
These types are opaque pointers managed entirely by libghostty. Never dereference these pointers directly.The main application instance. Manages global state, configuration, and coordinates multiple surfaces.Created with
ghostty_app_new() and freed with ghostty_app_free().Configuration object containing terminal settings and behavior.Created with
ghostty_config_new() and freed with ghostty_config_free().A terminal surface (a single terminal instance). Each surface represents one terminal that can be rendered.Created with
ghostty_surface_new() and freed with ghostty_surface_free().An inspector/debugger interface for viewing terminal state.Obtained with
ghostty_surface_inspector() and freed with ghostty_inspector_free().Platform Types
ghostty_platform_e
Defines the target platform for a surface.Invalid/uninitialized platform.
macOS platform with Metal rendering and NSView integration.
iOS platform with Metal rendering and UIView integration.
ghostty_platform_macos_s
Platform-specific data for macOS.Pointer to an NSView (cast to
void*). The terminal will render into this view using Metal.ghostty_platform_ios_s
Platform-specific data for iOS.Pointer to a UIView (cast to
void*). The terminal will render into this view using Metal.ghostty_platform_u
Union of platform-specific data.ghostty_platform_e.
Surface Configuration
ghostty_surface_config_s
Configuration for creating a new terminal surface.The target platform for this surface.
Platform-specific configuration data. Use the field corresponding to
platform_tag.Arbitrary pointer to user data. Retrieved with
ghostty_surface_userdata().Display scale factor (e.g., 2.0 for Retina displays). Used for high-DPI rendering.
Font size in points.
Initial working directory for the shell. NULL for user’s home directory.
Command to run instead of the default shell. NULL for default shell.
Array of environment variables to set for the shell.
Number of environment variables in
env_vars.Text to send to the terminal after initialization. NULL for no initial input.
If true, keep the terminal open after the command exits.
Context in which the surface is being created (window, tab, split).
ghostty_surface_context_e
Defines the UI context for a surface.Surface is the primary terminal in a window.
Surface is in a tab.
Surface is in a split pane.
ghostty_surface_size_s
Describes the size of a terminal surface.Number of character columns.
Number of character rows.
Width in pixels.
Height in pixels.
Width of a single character cell in pixels.
Height of a single character cell in pixels.
Runtime Configuration
ghostty_runtime_config_s
Configuration for runtime callbacks that libghostty uses to communicate with the host application.Arbitrary pointer passed to all callbacks. Retrieved with
ghostty_app_userdata().Whether the platform supports X11-style selection clipboard (middle-click paste).
Callback invoked when libghostty needs the event loop to wake up.
Callback invoked when the terminal performs an action (ring bell, change title, etc.).Return
true if the action was handled, false otherwise.Callback invoked when the terminal needs to read from the clipboard.
Callback invoked when the terminal needs confirmation before reading the clipboard (OSC 52).
Callback invoked when the terminal needs to write to the clipboard.
Callback invoked when a surface should be closed.
Clipboard Types
ghostty_clipboard_e
Clipboard selection type.Standard system clipboard (Ctrl+C/Ctrl+V).
X11 selection clipboard (middle-click paste).
ghostty_clipboard_content_s
Content for clipboard operations.MIME type of the content (e.g., “text/plain”, “text/html”).
The clipboard data as a null-terminated string.
ghostty_clipboard_request_e
Type of clipboard request.Utility Types
ghostty_string_s
A string returned by libghostty that must be freed.Pointer to the string data.
Length of the string in bytes.
If true, the string is null-terminated.
ghostty_string_free().
ghostty_info_s
Information about the libghostty build.The build mode (debug, release, etc.).
Version string (not null-terminated, use
version_len).Length of the version string.
ghostty_build_mode_e
ghostty_diagnostic_s
A configuration diagnostic (warning or error).Human-readable diagnostic message.
Color Types
ghostty_color_scheme_e
System color scheme preference.ghostty_config_color_s
RGB color value.Red component (0-255).
Green component (0-255).
Blue component (0-255).
Environment Variables
ghostty_env_var_s
An environment variable key-value pair.Environment variable name.
Environment variable value.
Constants
GHOSTTY_SUCCESS
ghostty_init().
See Also
- Configuration API - Configuration types and functions
- Input Types - Input-related types
- Actions - Action types and rendering