![]() |
libghostty
|
#include <limits.h>#include <stddef.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | GhosttyString |
| struct | GhosttyBuffer |
| struct | GhosttySurfacePosition |
| struct | GhosttyCodepoints |
Macros | |
| #define | GHOSTTY_ENUM_TYPED |
| #define | GHOSTTY_INIT_SIZED(type) |
Typedefs | |
| typedef struct GhosttyTerminalImpl * | GhosttyTerminal |
| typedef struct GhosttySnapshotDecoderImpl * | GhosttySnapshotDecoder |
| typedef struct GhosttyTrackedGridRefImpl * | GhosttyTrackedGridRef |
| 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 GhosttySearchImpl * | GhosttySearch |
| 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_IO_ERROR = -5 , GHOSTTY_LIMIT_EXCEEDED = -6 , GHOSTTY_REJECTED = -7 , GHOSTTY_RESULT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE } |
| enum | GhosttyFormatterFormat { GHOSTTY_FORMATTER_FORMAT_PLAIN , GHOSTTY_FORMATTER_FORMAT_VT , GHOSTTY_FORMATTER_FORMAT_HTML , GHOSTTY_FORMATTER_FORMAT_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.
C++11 and C23 support explicit enum underlying types with enum : int { ... }. Clang and GCC 13+ also support this syntax as an extension in older C language modes, so use it when available.
Other pre-C23 C compilers are free to choose any type that can represent all values (C11 ยง6.7.2.2). For those compilers, we add an INT_MAX sentinel as the last entry so the compatible type must be able to represent INT_MAX. The exact compatible type and its signedness remain implementation-defined in this fallback.
INT_MAX is used rather than a fixed constant like 0xFFFFFFFF because enum constants must have type int in pre-C23 C. Values above INT_MAX are a constraint violation there; compilers that accept them may 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 the versioned libghostty-vt C type manifest for the current target.
The manifest defines all the public types available in the linked build. The types contain their layouts, enum values, union fields, and more.
Language bindings, such as WebAssembly hosts, should obtain offsets, sizes, alignments, array shapes, enum constants, and tagged-union arms from this manifest rather than hardcoding them. Consumers should reject unknown schema versions and verify the descriptors they require at initialization.
Packed type descriptors define fields using lsb and width. lsb is relative to bit zero of the containing numerical value; for nested packed layouts it is relative to the immediate containing field. Tagged packed unions select an inline arm layout using the named tag field. These layouts describe the current linked build and are not a cross-version stability promise.
The formal format is defined by the libghostty-vt ABI manifest JSON Schema.
Example (abbreviated):
The returned pointer is valid for the lifetime of the process.
References ghostty_type_json().
Referenced by ghostty_type_json().