Files
ghostty/example/c-vt-colors/README.md
Mitchell Hashimoto 945920a186 vt: expose terminal default colors via C API
Add set/get support for foreground, background, cursor, and palette
default colors through ghostty_terminal_set and ghostty_terminal_get.

Four new set options (COLOR_FOREGROUND, COLOR_BACKGROUND, COLOR_CURSOR,
COLOR_PALETTE) write directly to the terminal color defaults. Passing
NULL clears the value for RGB colors or resets the palette to the
built-in default. All set operations mark the palette dirty flag for
the renderer.

Eight new get data types retrieve either the effective color (override
or default, via DynamicRGB.get) or the default color only (ignoring
any OSC overrides). Effective getters for RGB colors return the new
NO_VALUE result code when no color is configured. The palette getters
return the current or original palette respectively.

Adds the GHOSTTY_NO_VALUE result code for cases where a queried value
is simply not configured, distinct from GHOSTTY_INVALID_VALUE which
indicates a caller error.
2026-03-26 09:51:30 -07:00

525 B

Example: ghostty-vt Terminal Colors

This contains a simple example of how to set default terminal colors, read effective and default color values, and observe how OSC overrides layer on top of defaults using the ghostty-vt C library.

This uses a build.zig and Zig to build the C program so that we can reuse a lot of our build logic and depend directly on our source tree, but Ghostty emits a standard C library that can be used with any C tooling.

Usage

Run the program:

zig build run