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
197
typedef
struct
GhosttyRenderStateImageIteratorImpl*
GhosttyRenderStateImageIterator
;
198
210
typedef
struct
GhosttySearchImpl*
GhosttySearch
;
211
220
typedef
struct
GhosttySgrParserImpl*
GhosttySgrParser
;
221
227
typedef
struct
GhosttyFormatterImpl*
GhosttyFormatter
;
228
237
typedef
struct
GhosttyOscParserImpl*
GhosttyOscParser
;
238
247
typedef
struct
GhosttyOscCommandImpl*
GhosttyOscCommand
;
248
249
/* ---- Common value types ---- */
250
256
typedef
enum
GHOSTTY_ENUM_TYPED
{
258
GHOSTTY_FORMATTER_FORMAT_PLAIN
,
259
261
GHOSTTY_FORMATTER_FORMAT_VT
,
262
264
GHOSTTY_FORMATTER_FORMAT_HTML
,
265
GHOSTTY_FORMATTER_FORMAT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
266
}
GhosttyFormatterFormat
;
267
276
typedef
struct
{
278
const
uint8_t*
ptr
;
279
281
size_t
len
;
282
}
GhosttyString
;
283
290
typedef
struct
{
292
uint8_t*
ptr
;
293
295
size_t
cap
;
296
298
size_t
len
;
299
}
GhosttyBuffer
;
300
308
typedef
struct
{
310
double
x
;
311
313
double
y
;
314
}
GhosttySurfacePosition
;
315
325
typedef
struct
{
327
const
uint32_t*
ptr
;
328
330
size_t
len
;
331
}
GhosttyCodepoints
;
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
418
GHOSTTY_API
const
char
*
ghostty_type_json
(
void
);
419
420
#endif
/* GHOSTTY_VT_TYPES_H */
GhosttyFormatterFormat
GhosttyFormatterFormat
Definition
types.h:256
GhosttyFormatter
struct GhosttyFormatterImpl * GhosttyFormatter
Definition
types.h:227
GHOSTTY_FORMATTER_FORMAT_PLAIN
@ GHOSTTY_FORMATTER_FORMAT_PLAIN
Definition
types.h:258
GHOSTTY_FORMATTER_FORMAT_HTML
@ GHOSTTY_FORMATTER_FORMAT_HTML
Definition
types.h:264
GHOSTTY_FORMATTER_FORMAT_VT
@ GHOSTTY_FORMATTER_FORMAT_VT
Definition
types.h:261
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:237
GhosttyOscCommand
struct GhosttyOscCommandImpl * GhosttyOscCommand
Definition
types.h:247
GhosttyRenderStateRowIterator
struct GhosttyRenderStateRowIteratorImpl * GhosttyRenderStateRowIterator
Definition
types.h:182
GhosttyRenderState
struct GhosttyRenderStateImpl * GhosttyRenderState
Definition
types.h:175
GhosttyRenderStateImageIterator
struct GhosttyRenderStateImageIteratorImpl * GhosttyRenderStateImageIterator
Definition
types.h:197
GhosttyRenderStateRowCells
struct GhosttyRenderStateRowCellsImpl * GhosttyRenderStateRowCells
Definition
types.h:189
GhosttySearch
struct GhosttySearchImpl * GhosttySearch
Definition
types.h:210
GhosttySgrParser
struct GhosttySgrParserImpl * GhosttySgrParser
Definition
types.h:220
GhosttySnapshotDecoder
struct GhosttySnapshotDecoderImpl * GhosttySnapshotDecoder
Definition
types.h:126
GhosttyTerminal
struct GhosttyTerminalImpl * GhosttyTerminal
Definition
types.h:119
GhosttyBuffer
Definition
types.h:290
GhosttyBuffer::len
size_t len
Definition
types.h:298
GhosttyBuffer::cap
size_t cap
Definition
types.h:295
GhosttyBuffer::ptr
uint8_t * ptr
Definition
types.h:292
GhosttyCodepoints
Definition
types.h:325
GhosttyCodepoints::len
size_t len
Definition
types.h:330
GhosttyCodepoints::ptr
const uint32_t * ptr
Definition
types.h:327
GhosttyString
Definition
types.h:276
GhosttyString::len
size_t len
Definition
types.h:281
GhosttyString::ptr
const uint8_t * ptr
Definition
types.h:278
GhosttySurfacePosition
Definition
types.h:308
GhosttySurfacePosition::y
double y
Definition
types.h:313
GhosttySurfacePosition::x
double x
Definition
types.h:310
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