libghostty-vt
0.0.0
Toggle main menu visibility
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
40
extern
"C"
{
41
#endif
42
48
typedef
struct
{
49
uint8_t
r
;
50
uint8_t
g
;
51
uint8_t
b
;
52
}
GhosttyColorRgb
;
53
59
typedef
uint8_t
GhosttyColorPaletteIndex
;
60
78
typedef
struct
{
79
uint64_t bits[4];
80
}
GhosttyColorPaletteMask
;
81
87
typedef
struct
{
89
const
char
*
name
;
91
GhosttyColorRgb
color
;
92
}
GhosttyColorX11Entry
;
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
193
GHOSTTY_API
void
ghostty_color_rgb_get
(
const
GhosttyColorRgb
* color,
194
uint8_t* r,
195
uint8_t* g,
196
uint8_t* b);
197
213
GHOSTTY_API
GhosttyResult
ghostty_color_parse_x11
(
214
const
char
* name,
215
size_t
len,
216
GhosttyColorRgb
* out);
217
235
GHOSTTY_API
GhosttyResult
ghostty_color_parse
(
236
const
char
* value,
237
size_t
len,
238
GhosttyColorRgb
* out);
239
257
GHOSTTY_API
GhosttyResult
ghostty_color_parse_palette_entry
(
258
const
char
* value,
259
size_t
len,
260
uint8_t* out_index,
261
GhosttyColorRgb
* out_rgb);
262
274
GHOSTTY_API
void
ghostty_color_palette_default
(
GhosttyColorRgb
* out);
275
304
GHOSTTY_API
void
ghostty_color_palette_generate
(
305
const
GhosttyColorRgb
* base,
306
const
GhosttyColorPaletteMask
* skip,
307
const
GhosttyColorRgb
* bg,
308
const
GhosttyColorRgb
* fg,
309
bool
harmonious,
310
GhosttyColorRgb
* out);
311
323
GHOSTTY_API
double
ghostty_color_luminance
(
const
GhosttyColorRgb
* color);
324
338
GHOSTTY_API
double
ghostty_color_perceived_luminance
(
const
GhosttyColorRgb
* color);
339
352
GHOSTTY_API
double
ghostty_color_contrast
(
const
GhosttyColorRgb
* a,
353
const
GhosttyColorRgb
* b);
354
377
GHOSTTY_API
const
GhosttyColorX11Entry
*
ghostty_color_x11_names
(
void
);
378
389
GHOSTTY_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_color_x11_name_count
GHOSTTY_API size_t ghostty_color_x11_name_count(void)
ghostty_color_palette_generate
GHOSTTY_API void ghostty_color_palette_generate(const GhosttyColorRgb *base, const GhosttyColorPaletteMask *skip, const GhosttyColorRgb *bg, const GhosttyColorRgb *fg, bool harmonious, GhosttyColorRgb *out)
ghostty_color_perceived_luminance
GHOSTTY_API double ghostty_color_perceived_luminance(const GhosttyColorRgb *color)
ghostty_color_x11_names
GHOSTTY_API const GhosttyColorX11Entry * ghostty_color_x11_names(void)
ghostty_color_parse_palette_entry
GHOSTTY_API GhosttyResult ghostty_color_parse_palette_entry(const char *value, size_t len, uint8_t *out_index, GhosttyColorRgb *out_rgb)
ghostty_color_parse_x11
GHOSTTY_API GhosttyResult ghostty_color_parse_x11(const char *name, size_t len, GhosttyColorRgb *out)
ghostty_color_parse
GHOSTTY_API GhosttyResult ghostty_color_parse(const char *value, size_t len, GhosttyColorRgb *out)
GhosttyColorPaletteIndex
uint8_t GhosttyColorPaletteIndex
Definition
color.h:59
ghostty_color_contrast
GHOSTTY_API double ghostty_color_contrast(const GhosttyColorRgb *a, const GhosttyColorRgb *b)
ghostty_color_palette_default
GHOSTTY_API void ghostty_color_palette_default(GhosttyColorRgb *out)
ghostty_color_luminance
GHOSTTY_API double ghostty_color_luminance(const GhosttyColorRgb *color)
ghostty_color_rgb_get
GHOSTTY_API void ghostty_color_rgb_get(const GhosttyColorRgb *color, uint8_t *r, uint8_t *g, uint8_t *b)
GhosttyResult
GhosttyResult
Definition
types.h:143
GhosttyColorPaletteMask
Definition
color.h:78
GhosttyColorRgb
Definition
color.h:48
GhosttyColorRgb::g
uint8_t g
Definition
color.h:50
GhosttyColorRgb::b
uint8_t b
Definition
color.h:51
GhosttyColorRgb::r
uint8_t r
Definition
color.h:49
GhosttyColorX11Entry
Definition
color.h:87
GhosttyColorX11Entry::color
GhosttyColorRgb color
Definition
color.h:91
GhosttyColorX11Entry::name
const char * name
Definition
color.h:89
types.h
include
ghostty
vt
color.h
Generated by
1.17.0