libghostty
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
73
75#include <ghostty/vt/color.h>
76#include <ghostty/vt/result.h>
77#include <stdbool.h>
78#include <stddef.h>
79#include <stdint.h>
80
81#ifdef __cplusplus
82extern "C" {
83#endif
84
94
103typedef enum {
104 GHOSTTY_SGR_ATTR_UNSET = 0,
105 GHOSTTY_SGR_ATTR_UNKNOWN = 1,
106 GHOSTTY_SGR_ATTR_BOLD = 2,
107 GHOSTTY_SGR_ATTR_RESET_BOLD = 3,
108 GHOSTTY_SGR_ATTR_ITALIC = 4,
109 GHOSTTY_SGR_ATTR_RESET_ITALIC = 5,
110 GHOSTTY_SGR_ATTR_FAINT = 6,
111 GHOSTTY_SGR_ATTR_UNDERLINE = 7,
112 GHOSTTY_SGR_ATTR_RESET_UNDERLINE = 8,
113 GHOSTTY_SGR_ATTR_UNDERLINE_COLOR = 9,
114 GHOSTTY_SGR_ATTR_UNDERLINE_COLOR_256 = 10,
115 GHOSTTY_SGR_ATTR_RESET_UNDERLINE_COLOR = 11,
116 GHOSTTY_SGR_ATTR_OVERLINE = 12,
117 GHOSTTY_SGR_ATTR_RESET_OVERLINE = 13,
118 GHOSTTY_SGR_ATTR_BLINK = 14,
119 GHOSTTY_SGR_ATTR_RESET_BLINK = 15,
120 GHOSTTY_SGR_ATTR_INVERSE = 16,
121 GHOSTTY_SGR_ATTR_RESET_INVERSE = 17,
122 GHOSTTY_SGR_ATTR_INVISIBLE = 18,
123 GHOSTTY_SGR_ATTR_RESET_INVISIBLE = 19,
124 GHOSTTY_SGR_ATTR_STRIKETHROUGH = 20,
125 GHOSTTY_SGR_ATTR_RESET_STRIKETHROUGH = 21,
126 GHOSTTY_SGR_ATTR_DIRECT_COLOR_FG = 22,
127 GHOSTTY_SGR_ATTR_DIRECT_COLOR_BG = 23,
128 GHOSTTY_SGR_ATTR_BG_8 = 24,
129 GHOSTTY_SGR_ATTR_FG_8 = 25,
130 GHOSTTY_SGR_ATTR_RESET_FG = 26,
131 GHOSTTY_SGR_ATTR_RESET_BG = 27,
132 GHOSTTY_SGR_ATTR_BRIGHT_BG_8 = 28,
133 GHOSTTY_SGR_ATTR_BRIGHT_FG_8 = 29,
134 GHOSTTY_SGR_ATTR_BG_256 = 30,
135 GHOSTTY_SGR_ATTR_FG_256 = 31,
137
143typedef enum {
144 GHOSTTY_SGR_UNDERLINE_NONE = 0,
145 GHOSTTY_SGR_UNDERLINE_SINGLE = 1,
146 GHOSTTY_SGR_UNDERLINE_DOUBLE = 2,
147 GHOSTTY_SGR_UNDERLINE_CURLY = 3,
148 GHOSTTY_SGR_UNDERLINE_DOTTED = 4,
149 GHOSTTY_SGR_UNDERLINE_DASHED = 5,
151
160typedef struct {
161 const uint16_t* full_ptr;
162 size_t full_len;
163 const uint16_t* partial_ptr;
164 size_t partial_len;
166
176typedef union {
177 GhosttySgrUnknown unknown;
178 GhosttySgrUnderline underline;
179 GhosttyColorRgb underline_color;
180 GhosttyColorPaletteIndex underline_color_256;
181 GhosttyColorRgb direct_color_fg;
182 GhosttyColorRgb direct_color_bg;
185 GhosttyColorPaletteIndex bright_bg_8;
186 GhosttyColorPaletteIndex bright_fg_8;
189 uint64_t _padding[8];
191
204typedef struct {
208
224 GhosttySgrParser* parser);
225
238
251
283 const uint16_t* params,
284 const char* separators,
285 size_t len);
286
301
316 const uint16_t** ptr);
317
332 const uint16_t** ptr);
333
347
361 GhosttySgrAttribute* attr);
362
363#ifdef __wasm__
375
386#endif
387
388#ifdef __cplusplus
389}
390#endif
391
393
394#endif /* GHOSTTY_VT_SGR_H */
GhosttySgrAttributeTag ghostty_sgr_attribute_tag(GhosttySgrAttribute attr)
struct GhosttySgrParser * GhosttySgrParser
Definition sgr.h:93
bool ghostty_sgr_next(GhosttySgrParser parser, GhosttySgrAttribute *attr)
size_t ghostty_sgr_unknown_full(GhosttySgrUnknown unknown, const uint16_t **ptr)
GhosttyResult ghostty_sgr_new(const GhosttyAllocator *allocator, GhosttySgrParser *parser)
GhosttyResult ghostty_sgr_set_params(GhosttySgrParser parser, const uint16_t *params, const char *separators, size_t len)
void ghostty_sgr_free(GhosttySgrParser parser)
GhosttySgrUnderline
Definition sgr.h:143
uint8_t GhosttyColorPaletteIndex
Definition color.h:32
void ghostty_sgr_reset(GhosttySgrParser parser)
size_t ghostty_sgr_unknown_partial(GhosttySgrUnknown unknown, const uint16_t **ptr)
GhosttySgrAttributeValue * ghostty_sgr_attribute_value(GhosttySgrAttribute *attr)
GhosttySgrAttributeTag
Definition sgr.h:103
void ghostty_wasm_free_sgr_attribute(GhosttySgrAttribute *attr)
GhosttySgrAttribute * ghostty_wasm_alloc_sgr_attribute(void)
GhosttyResult
Definition result.h:13