![]() |
libghostty
|
#include <limits.h>#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | GhosttyString |
Macros | |
| #define | GHOSTTY_ENUM_TYPED |
| #define | GHOSTTY_INIT_SIZED(type) |
Typedefs | |
| typedef struct GhosttyTerminalImpl * | GhosttyTerminal |
| typedef struct GhosttyKittyGraphicsImpl * | GhosttyKittyGraphics |
| typedef const struct GhosttyKittyGraphicsImageImpl * | GhosttyKittyGraphicsImage |
| typedef struct GhosttyKittyGraphicsPlacementIteratorImpl * | GhosttyKittyGraphicsPlacementIterator |
| typedef struct GhosttyRenderStateImpl * | GhosttyRenderState |
| typedef struct GhosttyRenderStateRowIteratorImpl * | GhosttyRenderStateRowIterator |
| typedef struct GhosttyRenderStateRowCellsImpl * | GhosttyRenderStateRowCells |
| typedef struct GhosttySgrParserImpl * | GhosttySgrParser |
| typedef struct GhosttyFormatterImpl * | GhosttyFormatter |
| typedef struct GhosttyOscParserImpl * | GhosttyOscParser |
| typedef struct GhosttyOscCommandImpl * | GhosttyOscCommand |
Enumerations | |
| enum | GhosttyResult { GHOSTTY_SUCCESS = 0 , GHOSTTY_OUT_OF_MEMORY = -1 , GHOSTTY_INVALID_VALUE = -2 , GHOSTTY_OUT_OF_SPACE = -3 , GHOSTTY_NO_VALUE = -4 , GHOSTTY_RESULT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE } |
Functions | |
| GHOSTTY_API const char * | ghostty_type_json (void) |
Common types, macros, and utilities for libghostty-vt.
Definition in file types.h.
| #define GHOSTTY_ENUM_TYPED |
Enum int-sizing helpers.
The Zig side backs all C enums with c_int, so the C declarations must use int as their underlying type to maintain ABI compatibility.
C23 (detected via STDC_VERSION >= 202311L) supports explicit enum underlying types with enum : int { ... }. For pre-C23 compilers, which are free to choose any type that can represent all values (C11 ยง6.7.2.2), we add an INT_MAX sentinel as the last entry to force the compiler to use int.
INT_MAX is used rather than a fixed constant like 0xFFFFFFFF because enum constants must have type int (which is signed). Values above INT_MAX overflow signed int and are a constraint violation in standard C; compilers that accept them interpret them as negative values via two's complement, which can collide with legitimate negative enum values.
Usage:
| #define GHOSTTY_INIT_SIZED | ( | type | ) |
Initialize a sized struct to zero and set its size field.
Sized structs use a size field as the first member for ABI compatibility. This macro zero-initializes the struct and sets the size field to sizeof(type), which allows the library to detect which version of the struct the caller was compiled against.
| type | The struct type to initialize |
Example:
| enum GhosttyResult |
Result codes for libghostty-vt operations.
| GHOSTTY_API const char * ghostty_type_json | ( | void | ) |
Return a pointer to a null-terminated JSON string describing the layout of every C API struct for the current target.
This is primarily useful for language bindings that can't easily set C struct fields and need to do so via byte offsets. For example, WebAssembly modules can't share struct definitions with the host.
Example (abbreviated):
The returned pointer is valid for the lifetime of the process.