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
197typedef struct GhosttyRenderStateImageIteratorImpl* GhosttyRenderStateImageIterator;
198
210typedef struct GhosttySearchImpl* GhosttySearch;
211
220typedef struct GhosttySgrParserImpl* GhosttySgrParser;
221
227typedef struct GhosttyFormatterImpl* GhosttyFormatter;
228
237typedef struct GhosttyOscParserImpl* GhosttyOscParser;
238
247typedef struct GhosttyOscCommandImpl* GhosttyOscCommand;
248
249/* ---- Common value types ---- */
250
256typedef enum GHOSTTY_ENUM_TYPED {
259
262
265 GHOSTTY_FORMATTER_FORMAT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
267
276typedef struct {
278 const uint8_t* ptr;
279
281 size_t len;
283
290typedef struct {
292 uint8_t* ptr;
293
295 size_t cap;
296
298 size_t len;
300
308typedef struct {
310 double x;
311
313 double y;
315
325typedef struct {
327 const uint32_t* ptr;
328
330 size_t len;
332
351#ifdef __cplusplus
352#define GHOSTTY_INIT_SIZED(type) \
353 ([]() noexcept { \
354 type value{}; \
355 value.size = sizeof(value); \
356 return value; \
357 }())
358#else
359#define GHOSTTY_INIT_SIZED(type) \
360 ((type){ .size = sizeof(type) })
361#endif
362
418GHOSTTY_API const char *ghostty_type_json(void);
419
420#endif /* GHOSTTY_VT_TYPES_H */
GhosttyFormatterFormat
Definition types.h:256
struct GhosttyFormatterImpl * GhosttyFormatter
Definition types.h:227
@ GHOSTTY_FORMATTER_FORMAT_PLAIN
Definition types.h:258
@ GHOSTTY_FORMATTER_FORMAT_HTML
Definition types.h:264
@ GHOSTTY_FORMATTER_FORMAT_VT
Definition types.h:261
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:237
struct GhosttyOscCommandImpl * GhosttyOscCommand
Definition types.h:247
struct GhosttyRenderStateRowIteratorImpl * GhosttyRenderStateRowIterator
Definition types.h:182
struct GhosttyRenderStateImpl * GhosttyRenderState
Definition types.h:175
struct GhosttyRenderStateImageIteratorImpl * GhosttyRenderStateImageIterator
Definition types.h:197
struct GhosttyRenderStateRowCellsImpl * GhosttyRenderStateRowCells
Definition types.h:189
struct GhosttySearchImpl * GhosttySearch
Definition types.h:210
struct GhosttySgrParserImpl * GhosttySgrParser
Definition types.h:220
struct GhosttySnapshotDecoderImpl * GhosttySnapshotDecoder
Definition types.h:126
struct GhosttyTerminalImpl * GhosttyTerminal
Definition types.h:119
size_t len
Definition types.h:298
size_t cap
Definition types.h:295
uint8_t * ptr
Definition types.h:292
const uint32_t * ptr
Definition types.h:327
size_t len
Definition types.h:281
const uint8_t * ptr
Definition types.h:278
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