libghostty
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1
6
7#ifndef GHOSTTY_VT_TYPES_H
8#define GHOSTTY_VT_TYPES_H
9
10#include <limits.h>
11#include <stddef.h>
12#include <stdint.h>
13
14// Symbol visibility for shared library builds. On Windows, functions
15// are exported from the DLL when building and imported when consuming.
16// On other platforms with GCC/Clang, functions are marked with default
17// visibility so they remain accessible when the library is built with
18// -fvisibility=hidden. For static library builds, define GHOSTTY_STATIC
19// before including this header to make this a no-op.
20#ifndef GHOSTTY_API
21#if defined(GHOSTTY_STATIC)
22 #define GHOSTTY_API
23#elif defined(_WIN32) || defined(_WIN64)
24 #ifdef GHOSTTY_BUILD_SHARED
25 #define GHOSTTY_API __declspec(dllexport)
26 #else
27 #define GHOSTTY_API __declspec(dllimport)
28 #endif
29#elif defined(__GNUC__) && __GNUC__ >= 4
30 #define GHOSTTY_API __attribute__((visibility("default")))
31#else
32 #define GHOSTTY_API
33#endif
34#endif
35
67#if defined(__cplusplus) && \
68 (__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1700))
69#define GHOSTTY_ENUM_TYPED : int
70#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
71#define GHOSTTY_ENUM_TYPED : int
72#elif defined(__clang__)
73 #if __has_extension(c_fixed_enum)
74 #define GHOSTTY_ENUM_TYPED : int
75 #else
76 #define GHOSTTY_ENUM_TYPED
77 #endif
78#elif defined(__GNUC__) && __GNUC__ >= 13
79#define GHOSTTY_ENUM_TYPED : int
80#else
81#define GHOSTTY_ENUM_TYPED
82#endif
83#define GHOSTTY_ENUM_MAX_VALUE INT_MAX
84
88typedef enum GHOSTTY_ENUM_TYPED {
109 GHOSTTY_RESULT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
111
112/* ---- Opaque handles ---- */
113
119typedef struct GhosttyTerminalImpl* GhosttyTerminal;
120
126typedef struct GhosttySnapshotDecoderImpl* GhosttySnapshotDecoder;
127
138typedef struct GhosttyTrackedGridRefImpl* GhosttyTrackedGridRef;
139
150typedef struct GhosttyKittyGraphicsImpl* GhosttyKittyGraphics;
151
161typedef const struct GhosttyKittyGraphicsImageImpl* GhosttyKittyGraphicsImage;
162
168typedef struct GhosttyKittyGraphicsPlacementIteratorImpl* GhosttyKittyGraphicsPlacementIterator;
169
175typedef struct GhosttyRenderStateImpl* GhosttyRenderState;
176
182typedef struct GhosttyRenderStateRowIteratorImpl* GhosttyRenderStateRowIterator;
183
189typedef struct GhosttyRenderStateRowCellsImpl* GhosttyRenderStateRowCells;
190
202typedef struct GhosttySearchImpl* GhosttySearch;
203
212typedef struct GhosttySgrParserImpl* GhosttySgrParser;
213
219typedef struct GhosttyFormatterImpl* GhosttyFormatter;
220
229typedef struct GhosttyOscParserImpl* GhosttyOscParser;
230
239typedef struct GhosttyOscCommandImpl* GhosttyOscCommand;
240
241/* ---- Common value types ---- */
242
248typedef enum GHOSTTY_ENUM_TYPED {
251
254
257 GHOSTTY_FORMATTER_FORMAT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
259
266typedef struct {
268 const uint8_t* ptr;
269
271 size_t len;
273
280typedef struct {
282 uint8_t* ptr;
283
285 size_t cap;
286
288 size_t len;
290
298typedef struct {
300 double x;
301
303 double y;
305
315typedef struct {
317 const uint32_t* ptr;
318
320 size_t len;
322
341#ifdef __cplusplus
342#define GHOSTTY_INIT_SIZED(type) \
343 ([]() noexcept { \
344 type value{}; \
345 value.size = sizeof(value); \
346 return value; \
347 }())
348#else
349#define GHOSTTY_INIT_SIZED(type) \
350 ((type){ .size = sizeof(type) })
351#endif
352
408GHOSTTY_API const char *ghostty_type_json(void);
409
410#endif /* GHOSTTY_VT_TYPES_H */
GhosttyFormatterFormat
Definition types.h:248
struct GhosttyFormatterImpl * GhosttyFormatter
Definition types.h:219
@ GHOSTTY_FORMATTER_FORMAT_PLAIN
Definition types.h:250
@ GHOSTTY_FORMATTER_FORMAT_HTML
Definition types.h:256
@ GHOSTTY_FORMATTER_FORMAT_VT
Definition types.h:253
struct GhosttyTrackedGridRefImpl * GhosttyTrackedGridRef
Definition types.h:138
struct GhosttyKittyGraphicsImpl * GhosttyKittyGraphics
Definition types.h:150
struct GhosttyKittyGraphicsPlacementIteratorImpl * GhosttyKittyGraphicsPlacementIterator
Definition types.h:168
const struct GhosttyKittyGraphicsImageImpl * GhosttyKittyGraphicsImage
Definition types.h:161
struct GhosttyOscParserImpl * GhosttyOscParser
Definition types.h:229
struct GhosttyOscCommandImpl * GhosttyOscCommand
Definition types.h:239
struct GhosttyRenderStateRowIteratorImpl * GhosttyRenderStateRowIterator
Definition types.h:182
struct GhosttyRenderStateImpl * GhosttyRenderState
Definition types.h:175
struct GhosttyRenderStateRowCellsImpl * GhosttyRenderStateRowCells
Definition types.h:189
struct GhosttySearchImpl * GhosttySearch
Definition types.h:202
struct GhosttySgrParserImpl * GhosttySgrParser
Definition types.h:212
struct GhosttySnapshotDecoderImpl * GhosttySnapshotDecoder
Definition types.h:126
struct GhosttyTerminalImpl * GhosttyTerminal
Definition types.h:119
size_t len
Definition types.h:288
size_t cap
Definition types.h:285
uint8_t * ptr
Definition types.h:282
const uint32_t * ptr
Definition types.h:317
size_t len
Definition types.h:271
const uint8_t * ptr
Definition types.h:268
GhosttyResult
Definition types.h:88
@ GHOSTTY_OUT_OF_SPACE
Definition types.h:96
@ GHOSTTY_REJECTED
Definition types.h:108
@ GHOSTTY_INVALID_VALUE
Definition types.h:94
@ GHOSTTY_OUT_OF_MEMORY
Definition types.h:92
@ GHOSTTY_NO_VALUE
Definition types.h:98
@ GHOSTTY_LIMIT_EXCEEDED
Definition types.h:102
@ GHOSTTY_IO_ERROR
Definition types.h:100
@ GHOSTTY_SUCCESS
Definition types.h:90
GHOSTTY_API const char * ghostty_type_json(void)
#define GHOSTTY_ENUM_TYPED
Definition types.h:81