libghostty
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
115
116
#include <stdbool.h>
117
#include <stddef.h>
118
#include <stdint.h>
119
#include <
ghostty/vt/types.h
>
120
121
#ifdef __cplusplus
122
extern
"C"
{
123
#endif
124
130
typedef
struct
{
131
uint8_t
r
;
132
uint8_t
g
;
133
uint8_t
b
;
134
}
GhosttyColorRgb
;
135
141
typedef
uint8_t
GhosttyColorPaletteIndex
;
142
160
typedef
struct
{
161
uint64_t bits[4];
162
}
GhosttyColorPaletteMask
;
163
169
typedef
struct
{
171
const
char
*
name
;
173
GhosttyColorRgb
color
;
174
}
GhosttyColorX11Entry
;
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
275
GHOSTTY_API
void
ghostty_color_rgb_get
(
const
GhosttyColorRgb
* color,
276
uint8_t* r,
277
uint8_t* g,
278
uint8_t* b);
279
295
GHOSTTY_API
GhosttyResult
ghostty_color_parse_x11
(
296
const
char
* name,
297
size_t
len,
298
GhosttyColorRgb
* out);
299
317
GHOSTTY_API
GhosttyResult
ghostty_color_parse
(
318
const
char
* value,
319
size_t
len,
320
GhosttyColorRgb
* out);
321
339
GHOSTTY_API
GhosttyResult
ghostty_color_parse_palette_entry
(
340
const
char
* value,
341
size_t
len,
342
uint8_t* out_index,
343
GhosttyColorRgb
* out_rgb);
344
356
GHOSTTY_API
void
ghostty_color_palette_default
(
GhosttyColorRgb
* out);
357
386
GHOSTTY_API
void
ghostty_color_palette_generate
(
387
const
GhosttyColorRgb
* base,
388
const
GhosttyColorPaletteMask
* skip,
389
const
GhosttyColorRgb
* bg,
390
const
GhosttyColorRgb
* fg,
391
bool
harmonious,
392
GhosttyColorRgb
* out);
393
405
GHOSTTY_API
double
ghostty_color_luminance
(
const
GhosttyColorRgb
* color);
406
420
GHOSTTY_API
double
ghostty_color_perceived_luminance
(
const
GhosttyColorRgb
* color);
421
434
GHOSTTY_API
double
ghostty_color_contrast
(
const
GhosttyColorRgb
* a,
435
const
GhosttyColorRgb
* b);
436
459
GHOSTTY_API
const
GhosttyColorX11Entry
*
ghostty_color_x11_names
(
void
);
460
471
GHOSTTY_API
size_t
ghostty_color_x11_name_count
(
void
);
472
473
#ifdef __cplusplus
474
}
475
#endif
476
478
479
#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:141
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)
GhosttyColorPaletteMask
Definition
color.h:160
GhosttyColorRgb
Definition
color.h:130
GhosttyColorRgb::g
uint8_t g
Definition
color.h:132
GhosttyColorRgb::b
uint8_t b
Definition
color.h:133
GhosttyColorRgb::r
uint8_t r
Definition
color.h:131
GhosttyColorX11Entry
Definition
color.h:169
GhosttyColorX11Entry::color
GhosttyColorRgb color
Definition
color.h:173
GhosttyColorX11Entry::name
const char * name
Definition
color.h:171
types.h
GhosttyResult
GhosttyResult
Definition
types.h:88
include
ghostty
vt
color.h
Generated by
1.18.0