libghostty-vt 0.0.0
Loading...
Searching...
No Matches
color.h
Go to the documentation of this file.
1
6
7#ifndef GHOSTTY_VT_COLOR_H
8#define GHOSTTY_VT_COLOR_H
9
33
34#include <stdbool.h>
35#include <stddef.h>
36#include <stdint.h>
37#include <ghostty/vt/types.h>
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
48typedef struct {
49 uint8_t r;
50 uint8_t g;
51 uint8_t b;
53
60
78typedef struct {
79 uint64_t bits[4];
81
87typedef struct {
89 const char* name;
93
101#define GHOSTTY_COLOR_PALETTE_MASK_WORD(index) ((index) >> 6)
102
110#define GHOSTTY_COLOR_PALETTE_MASK_BIT(index) (UINT64_C(1) << ((index) & 63))
111
120#define GHOSTTY_COLOR_PALETTE_MASK_SET(mask, index) \
121 ((mask)->bits[GHOSTTY_COLOR_PALETTE_MASK_WORD(index)] |= GHOSTTY_COLOR_PALETTE_MASK_BIT(index))
122
131#define GHOSTTY_COLOR_PALETTE_MASK_UNSET(mask, index) \
132 ((mask)->bits[GHOSTTY_COLOR_PALETTE_MASK_WORD(index)] &= ~GHOSTTY_COLOR_PALETTE_MASK_BIT(index))
133
143#define GHOSTTY_COLOR_PALETTE_MASK_IS_SET(mask, index) \
144 (((mask)->bits[GHOSTTY_COLOR_PALETTE_MASK_WORD(index)] & GHOSTTY_COLOR_PALETTE_MASK_BIT(index)) != 0)
145
147#define GHOSTTY_COLOR_NAMED_BLACK 0
149#define GHOSTTY_COLOR_NAMED_RED 1
151#define GHOSTTY_COLOR_NAMED_GREEN 2
153#define GHOSTTY_COLOR_NAMED_YELLOW 3
155#define GHOSTTY_COLOR_NAMED_BLUE 4
157#define GHOSTTY_COLOR_NAMED_MAGENTA 5
159#define GHOSTTY_COLOR_NAMED_CYAN 6
161#define GHOSTTY_COLOR_NAMED_WHITE 7
163#define GHOSTTY_COLOR_NAMED_BRIGHT_BLACK 8
165#define GHOSTTY_COLOR_NAMED_BRIGHT_RED 9
167#define GHOSTTY_COLOR_NAMED_BRIGHT_GREEN 10
169#define GHOSTTY_COLOR_NAMED_BRIGHT_YELLOW 11
171#define GHOSTTY_COLOR_NAMED_BRIGHT_BLUE 12
173#define GHOSTTY_COLOR_NAMED_BRIGHT_MAGENTA 13
175#define GHOSTTY_COLOR_NAMED_BRIGHT_CYAN 14
177#define GHOSTTY_COLOR_NAMED_BRIGHT_WHITE 15
178
193GHOSTTY_API void ghostty_color_rgb_get(const GhosttyColorRgb* color,
194 uint8_t* r,
195 uint8_t* g,
196 uint8_t* b);
197
214 const char* name,
215 size_t len,
216 GhosttyColorRgb* out);
217
236 const char* value,
237 size_t len,
238 GhosttyColorRgb* out);
239
258 const char* value,
259 size_t len,
260 uint8_t* out_index,
261 GhosttyColorRgb* out_rgb);
262
275
305 const GhosttyColorRgb* base,
306 const GhosttyColorPaletteMask* skip,
307 const GhosttyColorRgb* bg,
308 const GhosttyColorRgb* fg,
309 bool harmonious,
310 GhosttyColorRgb* out);
311
323GHOSTTY_API double ghostty_color_luminance(const GhosttyColorRgb* color);
324
338GHOSTTY_API double ghostty_color_perceived_luminance(const GhosttyColorRgb* color);
339
352GHOSTTY_API double ghostty_color_contrast(const GhosttyColorRgb* a,
353 const GhosttyColorRgb* b);
354
378
389GHOSTTY_API size_t ghostty_color_x11_name_count(void);
390
391#ifdef __cplusplus
392}
393#endif
394
396
397#endif /* GHOSTTY_VT_COLOR_H */
GHOSTTY_API size_t ghostty_color_x11_name_count(void)
GHOSTTY_API void ghostty_color_palette_generate(const GhosttyColorRgb *base, const GhosttyColorPaletteMask *skip, const GhosttyColorRgb *bg, const GhosttyColorRgb *fg, bool harmonious, GhosttyColorRgb *out)
GHOSTTY_API double ghostty_color_perceived_luminance(const GhosttyColorRgb *color)
GHOSTTY_API const GhosttyColorX11Entry * ghostty_color_x11_names(void)
GHOSTTY_API GhosttyResult ghostty_color_parse_palette_entry(const char *value, size_t len, uint8_t *out_index, GhosttyColorRgb *out_rgb)
GHOSTTY_API GhosttyResult ghostty_color_parse_x11(const char *name, size_t len, GhosttyColorRgb *out)
GHOSTTY_API GhosttyResult ghostty_color_parse(const char *value, size_t len, GhosttyColorRgb *out)
uint8_t GhosttyColorPaletteIndex
Definition color.h:59
GHOSTTY_API double ghostty_color_contrast(const GhosttyColorRgb *a, const GhosttyColorRgb *b)
GHOSTTY_API void ghostty_color_palette_default(GhosttyColorRgb *out)
GHOSTTY_API double ghostty_color_luminance(const GhosttyColorRgb *color)
GHOSTTY_API void ghostty_color_rgb_get(const GhosttyColorRgb *color, uint8_t *r, uint8_t *g, uint8_t *b)
GhosttyResult
Definition types.h:143
uint8_t g
Definition color.h:50
uint8_t b
Definition color.h:51
uint8_t r
Definition color.h:49
Definition color.h:87
GhosttyColorRgb color
Definition color.h:91
const char * name
Definition color.h:89