libghostty
Toggle main menu visibility
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
88
typedef
enum
GHOSTTY_ENUM_TYPED
{
90
GHOSTTY_SUCCESS
= 0,
92
GHOSTTY_OUT_OF_MEMORY
= -1,
94
GHOSTTY_INVALID_VALUE
= -2,
96
GHOSTTY_OUT_OF_SPACE
= -3,
98
GHOSTTY_NO_VALUE
= -4,
100
GHOSTTY_IO_ERROR
= -5,
102
GHOSTTY_LIMIT_EXCEEDED
= -6,
108
GHOSTTY_REJECTED
= -7,
109
GHOSTTY_RESULT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
110
}
GhosttyResult
;
111
112
/* ---- Opaque handles ---- */
113
119
typedef
struct
GhosttyTerminalImpl*
GhosttyTerminal
;
120
126
typedef
struct
GhosttySnapshotDecoderImpl*
GhosttySnapshotDecoder
;
127
138
typedef
struct
GhosttyTrackedGridRefImpl*
GhosttyTrackedGridRef
;
139
150
typedef
struct
GhosttyKittyGraphicsImpl*
GhosttyKittyGraphics
;
151
161
typedef
const
struct
GhosttyKittyGraphicsImageImpl*
GhosttyKittyGraphicsImage
;
162
168
typedef
struct
GhosttyKittyGraphicsPlacementIteratorImpl*
GhosttyKittyGraphicsPlacementIterator
;
169
175
typedef
struct
GhosttyRenderStateImpl*
GhosttyRenderState
;
176
182
typedef
struct
GhosttyRenderStateRowIteratorImpl*
GhosttyRenderStateRowIterator
;
183
189
typedef
struct
GhosttyRenderStateRowCellsImpl*
GhosttyRenderStateRowCells
;
190
202
typedef
struct
GhosttySearchImpl*
GhosttySearch
;
203
212
typedef
struct
GhosttySgrParserImpl*
GhosttySgrParser
;
213
219
typedef
struct
GhosttyFormatterImpl*
GhosttyFormatter
;
220
229
typedef
struct
GhosttyOscParserImpl*
GhosttyOscParser
;
230
239
typedef
struct
GhosttyOscCommandImpl*
GhosttyOscCommand
;
240
241
/* ---- Common value types ---- */
242
248
typedef
enum
GHOSTTY_ENUM_TYPED
{
250
GHOSTTY_FORMATTER_FORMAT_PLAIN
,
251
253
GHOSTTY_FORMATTER_FORMAT_VT
,
254
256
GHOSTTY_FORMATTER_FORMAT_HTML
,
257
GHOSTTY_FORMATTER_FORMAT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
258
}
GhosttyFormatterFormat
;
259
266
typedef
struct
{
268
const
uint8_t*
ptr
;
269
271
size_t
len
;
272
}
GhosttyString
;
273
280
typedef
struct
{
282
uint8_t*
ptr
;
283
285
size_t
cap
;
286
288
size_t
len
;
289
}
GhosttyBuffer
;
290
298
typedef
struct
{
300
double
x
;
301
303
double
y
;
304
}
GhosttySurfacePosition
;
305
315
typedef
struct
{
317
const
uint32_t*
ptr
;
318
320
size_t
len
;
321
}
GhosttyCodepoints
;
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
408
GHOSTTY_API
const
char
*
ghostty_type_json
(
void
);
409
410
#endif
/* GHOSTTY_VT_TYPES_H */
GhosttyFormatterFormat
GhosttyFormatterFormat
Definition
types.h:248
GhosttyFormatter
struct GhosttyFormatterImpl * GhosttyFormatter
Definition
types.h:219
GHOSTTY_FORMATTER_FORMAT_PLAIN
@ GHOSTTY_FORMATTER_FORMAT_PLAIN
Definition
types.h:250
GHOSTTY_FORMATTER_FORMAT_HTML
@ GHOSTTY_FORMATTER_FORMAT_HTML
Definition
types.h:256
GHOSTTY_FORMATTER_FORMAT_VT
@ GHOSTTY_FORMATTER_FORMAT_VT
Definition
types.h:253
GhosttyTrackedGridRef
struct GhosttyTrackedGridRefImpl * GhosttyTrackedGridRef
Definition
types.h:138
GhosttyKittyGraphics
struct GhosttyKittyGraphicsImpl * GhosttyKittyGraphics
Definition
types.h:150
GhosttyKittyGraphicsPlacementIterator
struct GhosttyKittyGraphicsPlacementIteratorImpl * GhosttyKittyGraphicsPlacementIterator
Definition
types.h:168
GhosttyKittyGraphicsImage
const struct GhosttyKittyGraphicsImageImpl * GhosttyKittyGraphicsImage
Definition
types.h:161
GhosttyOscParser
struct GhosttyOscParserImpl * GhosttyOscParser
Definition
types.h:229
GhosttyOscCommand
struct GhosttyOscCommandImpl * GhosttyOscCommand
Definition
types.h:239
GhosttyRenderStateRowIterator
struct GhosttyRenderStateRowIteratorImpl * GhosttyRenderStateRowIterator
Definition
types.h:182
GhosttyRenderState
struct GhosttyRenderStateImpl * GhosttyRenderState
Definition
types.h:175
GhosttyRenderStateRowCells
struct GhosttyRenderStateRowCellsImpl * GhosttyRenderStateRowCells
Definition
types.h:189
GhosttySearch
struct GhosttySearchImpl * GhosttySearch
Definition
types.h:202
GhosttySgrParser
struct GhosttySgrParserImpl * GhosttySgrParser
Definition
types.h:212
GhosttySnapshotDecoder
struct GhosttySnapshotDecoderImpl * GhosttySnapshotDecoder
Definition
types.h:126
GhosttyTerminal
struct GhosttyTerminalImpl * GhosttyTerminal
Definition
types.h:119
GhosttyBuffer
Definition
types.h:280
GhosttyBuffer::len
size_t len
Definition
types.h:288
GhosttyBuffer::cap
size_t cap
Definition
types.h:285
GhosttyBuffer::ptr
uint8_t * ptr
Definition
types.h:282
GhosttyCodepoints
Definition
types.h:315
GhosttyCodepoints::len
size_t len
Definition
types.h:320
GhosttyCodepoints::ptr
const uint32_t * ptr
Definition
types.h:317
GhosttyString
Definition
types.h:266
GhosttyString::len
size_t len
Definition
types.h:271
GhosttyString::ptr
const uint8_t * ptr
Definition
types.h:268
GhosttySurfacePosition
Definition
types.h:298
GhosttySurfacePosition::y
double y
Definition
types.h:303
GhosttySurfacePosition::x
double x
Definition
types.h:300
GhosttyResult
GhosttyResult
Definition
types.h:88
GHOSTTY_OUT_OF_SPACE
@ GHOSTTY_OUT_OF_SPACE
Definition
types.h:96
GHOSTTY_REJECTED
@ GHOSTTY_REJECTED
Definition
types.h:108
GHOSTTY_INVALID_VALUE
@ GHOSTTY_INVALID_VALUE
Definition
types.h:94
GHOSTTY_OUT_OF_MEMORY
@ GHOSTTY_OUT_OF_MEMORY
Definition
types.h:92
GHOSTTY_NO_VALUE
@ GHOSTTY_NO_VALUE
Definition
types.h:98
GHOSTTY_LIMIT_EXCEEDED
@ GHOSTTY_LIMIT_EXCEEDED
Definition
types.h:102
GHOSTTY_IO_ERROR
@ GHOSTTY_IO_ERROR
Definition
types.h:100
GHOSTTY_SUCCESS
@ GHOSTTY_SUCCESS
Definition
types.h:90
ghostty_type_json
GHOSTTY_API const char * ghostty_type_json(void)
GHOSTTY_ENUM_TYPED
#define GHOSTTY_ENUM_TYPED
Definition
types.h:81
include
ghostty
vt
types.h
Generated by
1.18.0