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
41
43#include <ghostty/vt/color.h>
44#include <ghostty/vt/types.h>
45#include <stdbool.h>
46#include <stddef.h>
47#include <stdint.h>
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
61typedef enum GHOSTTY_ENUM_TYPED {
62 GHOSTTY_SGR_ATTR_UNSET = 0,
63 GHOSTTY_SGR_ATTR_UNKNOWN = 1,
64 GHOSTTY_SGR_ATTR_BOLD = 2,
65 GHOSTTY_SGR_ATTR_RESET_BOLD = 3,
66 GHOSTTY_SGR_ATTR_ITALIC = 4,
67 GHOSTTY_SGR_ATTR_RESET_ITALIC = 5,
68 GHOSTTY_SGR_ATTR_FAINT = 6,
69 GHOSTTY_SGR_ATTR_UNDERLINE = 7,
70 GHOSTTY_SGR_ATTR_UNDERLINE_COLOR = 8,
71 GHOSTTY_SGR_ATTR_UNDERLINE_COLOR_256 = 9,
72 GHOSTTY_SGR_ATTR_RESET_UNDERLINE_COLOR = 10,
73 GHOSTTY_SGR_ATTR_OVERLINE = 11,
74 GHOSTTY_SGR_ATTR_RESET_OVERLINE = 12,
75 GHOSTTY_SGR_ATTR_BLINK = 13,
76 GHOSTTY_SGR_ATTR_RESET_BLINK = 14,
77 GHOSTTY_SGR_ATTR_INVERSE = 15,
78 GHOSTTY_SGR_ATTR_RESET_INVERSE = 16,
79 GHOSTTY_SGR_ATTR_INVISIBLE = 17,
80 GHOSTTY_SGR_ATTR_RESET_INVISIBLE = 18,
81 GHOSTTY_SGR_ATTR_STRIKETHROUGH = 19,
82 GHOSTTY_SGR_ATTR_RESET_STRIKETHROUGH = 20,
83 GHOSTTY_SGR_ATTR_DIRECT_COLOR_FG = 21,
84 GHOSTTY_SGR_ATTR_DIRECT_COLOR_BG = 22,
85 GHOSTTY_SGR_ATTR_BG_8 = 23,
86 GHOSTTY_SGR_ATTR_FG_8 = 24,
87 GHOSTTY_SGR_ATTR_RESET_FG = 25,
88 GHOSTTY_SGR_ATTR_RESET_BG = 26,
89 GHOSTTY_SGR_ATTR_BRIGHT_BG_8 = 27,
90 GHOSTTY_SGR_ATTR_BRIGHT_FG_8 = 28,
91 GHOSTTY_SGR_ATTR_BG_256 = 29,
92 GHOSTTY_SGR_ATTR_FG_256 = 30,
93 GHOSTTY_SGR_ATTR_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
95
101typedef enum GHOSTTY_ENUM_TYPED {
102 GHOSTTY_SGR_UNDERLINE_NONE = 0,
103 GHOSTTY_SGR_UNDERLINE_SINGLE = 1,
104 GHOSTTY_SGR_UNDERLINE_DOUBLE = 2,
105 GHOSTTY_SGR_UNDERLINE_CURLY = 3,
106 GHOSTTY_SGR_UNDERLINE_DOTTED = 4,
107 GHOSTTY_SGR_UNDERLINE_DASHED = 5,
108 GHOSTTY_SGR_UNDERLINE_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
110
119typedef struct {
120 const uint16_t* full_ptr;
121 size_t full_len;
122 const uint16_t* partial_ptr;
123 size_t partial_len;
125
135typedef union {
136 GhosttySgrUnknown unknown;
137 GhosttySgrUnderline underline;
138 GhosttyColorRgb underline_color;
139 GhosttyColorPaletteIndex underline_color_256;
140 GhosttyColorRgb direct_color_fg;
141 GhosttyColorRgb direct_color_bg;
144 GhosttyColorPaletteIndex bright_bg_8;
145 GhosttyColorPaletteIndex bright_fg_8;
148 uint64_t _padding[8];
150
163typedef struct {
167
182GHOSTTY_API GhosttyResult ghostty_sgr_new(const GhosttyAllocator* allocator,
183 GhosttySgrParser* parser);
184
196GHOSTTY_API void ghostty_sgr_free(GhosttySgrParser parser);
197
209GHOSTTY_API void ghostty_sgr_reset(GhosttySgrParser parser);
210
242 const uint16_t* params,
243 const char* separators,
244 size_t len);
245
260
275 const uint16_t** ptr);
276
291 const uint16_t** ptr);
292
306
320 GhosttySgrAttribute* attr);
321
322#ifdef __wasm__
334
345#endif
346
347#ifdef __cplusplus
348}
349#endif
350
352
353#endif /* GHOSTTY_VT_SGR_H */
uint8_t GhosttyColorPaletteIndex
Definition color.h:141
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:101
struct GhosttySgrParserImpl * GhosttySgrParser
Definition types.h:168
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(GhosttySgrAttribute attr)
GhosttySgrAttributeTag
Definition sgr.h:61
GHOSTTY_API GhosttySgrAttribute * ghostty_wasm_alloc_sgr_attribute(void)
GHOSTTY_API void ghostty_wasm_free_sgr_attribute(GhosttySgrAttribute *attr)
GhosttyResult
Definition types.h:74
#define GHOSTTY_ENUM_TYPED
Definition types.h:67