Imported from JerryLeeSir/NotTerminal (
Vendor/GhosttySource/src/terminal/c/AGENTS.md). Install upstream withnpx skills add JerryLeeSir/NotTerminal --skill c. Copyright stays with the author.
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.