libghostty-vt 0.0.0
Loading...
Searching...
No Matches
sgr.h
Go to the documentation of this file.
1
6
7#ifndef GHOSTTY_VT_SGR_H
8#define GHOSTTY_VT_SGR_H
9
30
32#include <ghostty/vt/color.h>
33#include <ghostty/vt/types.h>
34#include <stdbool.h>
35#include <stddef.h>
36#include <stdint.h>
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
50typedef enum GHOSTTY_ENUM_TYPED {
51 GHOSTTY_SGR_ATTR_UNSET = 0,
52 GHOSTTY_SGR_ATTR_UNKNOWN = 1,
53 GHOSTTY_SGR_ATTR_BOLD = 2,
54 GHOSTTY_SGR_ATTR_RESET_BOLD = 3,
55 GHOSTTY_SGR_ATTR_ITALIC = 4,
56 GHOSTTY_SGR_ATTR_RESET_ITALIC = 5,
57 GHOSTTY_SGR_ATTR_FAINT = 6,
58 GHOSTTY_SGR_ATTR_UNDERLINE = 7,
59 GHOSTTY_SGR_ATTR_UNDERLINE_COLOR = 8,
60 GHOSTTY_SGR_ATTR_UNDERLINE_COLOR_256 = 9,
61 GHOSTTY_SGR_ATTR_RESET_UNDERLINE_COLOR = 10,
62 GHOSTTY_SGR_ATTR_OVERLINE = 11,
63 GHOSTTY_SGR_ATTR_RESET_OVERLINE = 12,
64 GHOSTTY_SGR_ATTR_BLINK = 13,
65 GHOSTTY_SGR_ATTR_RESET_BLINK = 14,
66 GHOSTTY_SGR_ATTR_INVERSE = 15,
67 GHOSTTY_SGR_ATTR_RESET_INVERSE = 16,
68 GHOSTTY_SGR_ATTR_INVISIBLE = 17,
69 GHOSTTY_SGR_ATTR_RESET_INVISIBLE = 18,
70 GHOSTTY_SGR_ATTR_STRIKETHROUGH = 19,
71 GHOSTTY_SGR_ATTR_RESET_STRIKETHROUGH = 20,
72 GHOSTTY_SGR_ATTR_DIRECT_COLOR_FG = 21,
73 GHOSTTY_SGR_ATTR_DIRECT_COLOR_BG = 22,
74 GHOSTTY_SGR_ATTR_BG_8 = 23,
75 GHOSTTY_SGR_ATTR_FG_8 = 24,
76 GHOSTTY_SGR_ATTR_RESET_FG = 25,
77 GHOSTTY_SGR_ATTR_RESET_BG = 26,
78 GHOSTTY_SGR_ATTR_BRIGHT_BG_8 = 27,
79 GHOSTTY_SGR_ATTR_BRIGHT_FG_8 = 28,
80 GHOSTTY_SGR_ATTR_BG_256 = 29,
81 GHOSTTY_SGR_ATTR_FG_256 = 30,
82 GHOSTTY_SGR_ATTR_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
84
90typedef enum GHOSTTY_ENUM_TYPED {
91 GHOSTTY_SGR_UNDERLINE_NONE = 0,
92 GHOSTTY_SGR_UNDERLINE_SINGLE = 1,
93 GHOSTTY_SGR_UNDERLINE_DOUBLE = 2,
94 GHOSTTY_SGR_UNDERLINE_CURLY = 3,
95 GHOSTTY_SGR_UNDERLINE_DOTTED = 4,
96 GHOSTTY_SGR_UNDERLINE_DASHED = 5,
97 GHOSTTY_SGR_UNDERLINE_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
99
108typedef struct {
109 const uint16_t* full_ptr;
110 size_t full_len;
111 const uint16_t* partial_ptr;
112 size_t partial_len;
114
124typedef union {
125 GhosttySgrUnknown unknown;
126 GhosttySgrUnderline underline;
127 GhosttyColorRgb underline_color;
128 GhosttyColorPaletteIndex underline_color_256;
129 GhosttyColorRgb direct_color_fg;
130 GhosttyColorRgb direct_color_bg;
133 GhosttyColorPaletteIndex bright_bg_8;
134 GhosttyColorPaletteIndex bright_fg_8;
137 uint64_t _padding[8];
139
156typedef struct {
160
175GHOSTTY_API GhosttyResult ghostty_sgr_new(const GhosttyAllocator* allocator,
176 GhosttySgrParser* parser);
177
189GHOSTTY_API void ghostty_sgr_free(GhosttySgrParser parser);
190
202GHOSTTY_API void ghostty_sgr_reset(GhosttySgrParser parser);
203
235 const uint16_t* params,
236 const char* separators,
237 size_t len);
238
253
268 const uint16_t** ptr);
269
284 const uint16_t** ptr);
285
299 const GhosttySgrAttribute* attr);
300
314 GhosttySgrAttribute* attr);
315
316#ifdef __cplusplus
317}
318#endif
319
321
322#endif /* GHOSTTY_VT_SGR_H */
uint8_t GhosttyColorPaletteIndex
Definition color.h:59
GhosttyResult
Definition types.h:143
#define GHOSTTY_ENUM_TYPED
Definition types.h:124
GHOSTTY_API size_t ghostty_sgr_unknown_partial(GhosttySgrUnknown unknown, const uint16_t **ptr)
GHOSTTY_API size_t ghostty_sgr_unknown_full(GhosttySgrUnknown unknown, const uint16_t **ptr)
GHOSTTY_API void ghostty_sgr_free(GhosttySgrParser parser)
GHOSTTY_API GhosttySgrAttributeValue * ghostty_sgr_attribute_value(GhosttySgrAttribute *attr)
GhosttySgrUnderline
Definition sgr.h:90
struct GhosttySgrParserImpl * GhosttySgrParser
Definition types.h:297
GHOSTTY_API GhosttyResult ghostty_sgr_set_params(GhosttySgrParser parser, const uint16_t *params, const char *separators, size_t len)
GHOSTTY_API GhosttyResult ghostty_sgr_new(const GhosttyAllocator *allocator, GhosttySgrParser *parser)
GHOSTTY_API bool ghostty_sgr_next(GhosttySgrParser parser, GhosttySgrAttribute *attr)
GHOSTTY_API void ghostty_sgr_reset(GhosttySgrParser parser)
GHOSTTY_API GhosttySgrAttributeTag ghostty_sgr_attribute_tag(const GhosttySgrAttribute *attr)
GhosttySgrAttributeTag
Definition sgr.h:50