mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-21 23:05:20 +00:00
Add a C API for iterating over Kitty graphics placements via the new GhosttyKittyGraphics opaque handle. The API follows the same pattern as the render state row iterator: allocate an iterator with ghostty_kitty_graphics_placement_iterator_new, populate it from a graphics handle via ghostty_kitty_graphics_get with the PLACEMENT_ITERATOR data kind, advance with ghostty_kitty_graphics_placement_next, and query per-placement fields with ghostty_kitty_graphics_placement_get.
1.2 KiB
1.2 KiB
libghostty-vt C API
- C API must be designed with ABI compatibility in mind
- Zig tagged unions must be converted to C ABI compatible unions
via
lib.TaggedUnion. - Any functions must be updated all the way through from here to
src/terminal/c/main.zigtosrc/lib_vt.zigand the headers ininclude/ghostty/vt.h. Specifically:- Define the function in
src/terminal/c/<module>.zig. - Re-export it via a
pub constinsrc/terminal/c/main.zig. - Add an
@exportcall insrc/lib_vt.zigwith theghostty_prefixed symbol name. - Declare it in the corresponding header under
include/ghostty/vt/.
- Define the function in
- In
include/ghostty/vt.h, always sort the header contents by: (1) macros, (2) forward declarations, (3) types, (4) functions
ABI Compatibility
- Prefer opaque pointers for long-lived objects, such as
GhosttyTerminal. - Structs:
- May contain padding bytes if we're confident we'll never grow beyond a certain size.
- May use the "sized struct" pattern: an
extern structwithsize: usize = @sizeOf(Self)as the first field. In the C header, callers useGHOSTTY_INIT_SIZEDfromtypes.hto zero-initialize and set the size.