libghostty
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
115
116#include <stdbool.h>
117#include <stddef.h>
118#include <stdint.h>
119#include <ghostty/vt/types.h>
120
121#ifdef __cplusplus
122extern "C" {
123#endif
124
130typedef struct {
131 uint8_t r;
132 uint8_t g;
133 uint8_t b;
135
142
160typedef struct {
161 uint64_t bits[4];
163
169typedef struct {
171 const char* name;
175
183#define GHOSTTY_COLOR_PALETTE_MASK_WORD(index) ((index) >> 6)
184
192#define GHOSTTY_COLOR_PALETTE_MASK_BIT(index) (UINT64_C(1) << ((index) & 63))
193
202#define GHOSTTY_COLOR_PALETTE_MASK_SET(mask, index) \
203 ((mask)->bits[GHOSTTY_COLOR_PALETTE_MASK_WORD(index)] |= GHOSTTY_COLOR_PALETTE_MASK_BIT(index))
204
213#define GHOSTTY_COLOR_PALETTE_MASK_UNSET(mask, index) \
214 ((mask)->bits[GHOSTTY_COLOR_PALETTE_MASK_WORD(index)] &= ~GHOSTTY_COLOR_PALETTE_MASK_BIT(index))
215
225#define GHOSTTY_COLOR_PALETTE_MASK_IS_SET(mask, index) \
226 (((mask)->bits[GHOSTTY_COLOR_PALETTE_MASK_WORD(index)] & GHOSTTY_COLOR_PALETTE_MASK_BIT(index)) != 0)
227
229#define GHOSTTY_COLOR_NAMED_BLACK 0
231#define GHOSTTY_COLOR_NAMED_RED 1
233#define GHOSTTY_COLOR_NAMED_GREEN 2
235#define GHOSTTY_COLOR_NAMED_YELLOW 3
237#define GHOSTTY_COLOR_NAMED_BLUE 4
239#define GHOSTTY_COLOR_NAMED_MAGENTA 5
241#define GHOSTTY_COLOR_NAMED_CYAN 6
243#define GHOSTTY_COLOR_NAMED_WHITE 7
245#define GHOSTTY_COLOR_NAMED_BRIGHT_BLACK 8
247#define GHOSTTY_COLOR_NAMED_BRIGHT_RED 9
249#define GHOSTTY_COLOR_NAMED_BRIGHT_GREEN 10
251#define GHOSTTY_COLOR_NAMED_BRIGHT_YELLOW 11
253#define GHOSTTY_COLOR_NAMED_BRIGHT_BLUE 12
255#define GHOSTTY_COLOR_NAMED_BRIGHT_MAGENTA 13
257#define GHOSTTY_COLOR_NAMED_BRIGHT_CYAN 14
259#define GHOSTTY_COLOR_NAMED_BRIGHT_WHITE 15
260
276 uint8_t* r,
277 uint8_t* g,
278 uint8_t* b);
279
296 const char* name,
297 size_t len,
298 GhosttyColorRgb* out);
299
318 const char* value,
319 size_t len,
320 GhosttyColorRgb* out);
321
340 const char* value,
341 size_t len,
342 uint8_t* out_index,
343 GhosttyColorRgb* out_rgb);
344
357
387 const GhosttyColorRgb* base,
388 const GhosttyColorPaletteMask* skip,
391 bool harmonious,
392 GhosttyColorRgb* out);
393
405GHOSTTY_API double ghostty_color_luminance(GhosttyColorRgb color);
406
421
435
459
470GHOSTTY_API size_t ghostty_color_x11_name_count(void);
471
472#ifdef __cplusplus
473}
474#endif
475
477
478#endif /* GHOSTTY_VT_COLOR_H */
GHOSTTY_API size_t ghostty_color_x11_name_count(void)
GHOSTTY_API void ghostty_color_rgb_get(GhosttyColorRgb color, uint8_t *r, uint8_t *g, uint8_t *b)
GHOSTTY_API const GhosttyColorX11Entry * ghostty_color_x11_names(void)
GHOSTTY_API double ghostty_color_perceived_luminance(GhosttyColorRgb color)
GHOSTTY_API GhosttyResult ghostty_color_parse_palette_entry(const char *value, size_t len, uint8_t *out_index, GhosttyColorRgb *out_rgb)
GHOSTTY_API void ghostty_color_palette_generate(const GhosttyColorRgb *base, const GhosttyColorPaletteMask *skip, GhosttyColorRgb bg, GhosttyColorRgb fg, bool harmonious, GhosttyColorRgb *out)
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:141
GHOSTTY_API double ghostty_color_contrast(GhosttyColorRgb a, GhosttyColorRgb b)
GHOSTTY_API void ghostty_color_palette_default(GhosttyColorRgb *out)
GHOSTTY_API double ghostty_color_luminance(GhosttyColorRgb color)
uint8_t g
Definition color.h:132
uint8_t b
Definition color.h:133
uint8_t r
Definition color.h:131
GhosttyColorRgb color
Definition color.h:173
const char * name
Definition color.h:171
GhosttyResult
Definition types.h:74