ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
colorscheme.h
Go to the documentation of this file.
1
30#pragma once
31
32#include "../common.h"
33#include "../platform/terminal.h"
35
36#ifdef __cplusplus
37extern "C" {
38#endif
39
40/* ============================================================================
41 * Color Definitions
42 * ============================================================================ */
43
55
62typedef struct color_scheme_t {
63 char name[64];
64 char description[256];
66 /* Dark mode colors (default, 8 colors for log levels) */
69 /* Light mode colors (optional) */
73 /* Metadata */
77
85typedef struct {
86 const char *codes_16[8];
87 const char *codes_256[8];
88 const char *codes_truecolor[8];
90
91/* ============================================================================
92 * Color System API
93 * ============================================================================ */
94
102
108void colorscheme_destroy(void);
109
117
127
137
148
161 terminal_background_t background, compiled_color_scheme_t *compiled);
162
170
179asciichat_error_t colorscheme_export_scheme(const char *scheme_name, const char *file_path);
180
181/* ============================================================================
182 * Color Conversion Utilities
183 * ============================================================================ */
184
195asciichat_error_t parse_hex_color(const char *hex, uint8_t *r, uint8_t *g, uint8_t *b);
196
197/* Note: rgb_to_16color() and rgb_to_256color() are defined in lib/video/ansi_fast.h
198 * To use them in colors.c, include ansi_fast.h */
199
210void rgb_to_truecolor_ansi(uint8_t r, uint8_t g, uint8_t b, char *buf, size_t size);
211
212/* ============================================================================
213 * Terminal Background Detection
214 * ============================================================================ */
215
227
228/* ============================================================================
229 * Early Color Initialization (for main() before log_init)
230 * ============================================================================ */
231
243asciichat_error_t options_colorscheme_init_early(int argc, const char *const argv[]);
244
245/* ============================================================================
246 * Internal: Shared Mutex for Color Compilation
247 * ============================================================================ */
248
257
258#ifdef __cplusplus
259}
260#endif
asciichat_error_t options_colorscheme_init_early(int argc, const char *const argv[])
Initialize color scheme early, before logging.
asciichat_error_t colorscheme_export_scheme(const char *scheme_name, const char *file_path)
Export a color scheme to TOML format.
asciichat_error_t colorscheme_init(void)
Initialize the color system.
asciichat_error_t parse_hex_color(const char *hex, uint8_t *r, uint8_t *g, uint8_t *b)
Parse a hex color string.
asciichat_error_t colorscheme_load_builtin(const char *name, color_scheme_t *scheme)
Load a built-in color scheme.
const color_scheme_t * colorscheme_get_active_scheme(void)
Get currently active color scheme.
terminal_background_t
Terminal theme detection result.
Definition colorscheme.h:50
@ TERM_BACKGROUND_DARK
Definition colorscheme.h:53
@ TERM_BACKGROUND_UNKNOWN
Definition colorscheme.h:51
@ TERM_BACKGROUND_LIGHT
Definition colorscheme.h:52
terminal_background_t detect_terminal_background(void)
Detect terminal background (light or dark)
asciichat_error_t colorscheme_load_from_file(const char *path, color_scheme_t *scheme)
Load a color scheme from a TOML file.
void colorscheme_destroy(void)
Shutdown the color system.
asciichat_error_t colorscheme_set_active_scheme(const char *name)
Set the active color scheme.
asciichat_error_t colorscheme_compile_scheme(const color_scheme_t *scheme, terminal_color_mode_t mode, terminal_background_t background, compiled_color_scheme_t *compiled)
Compile a color scheme to ANSI codes.
void rgb_to_truecolor_ansi(uint8_t r, uint8_t g, uint8_t b, char *buf, size_t size)
Generate truecolor ANSI escape code.
void colorscheme_cleanup_compiled(compiled_color_scheme_t *compiled)
Clean up allocated strings in a compiled color scheme.
mutex_t g_colorscheme_mutex
Shared mutex for color scheme compilation.
Definition colorscheme.c:39
unsigned char uint8_t
Definition common.h:56
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:49
char file_path[PLATFORM_MAX_PATH_LENGTH]
Definition mmap.c:39
Color scheme definition.
Definition colorscheme.h:62
rgb_pixel_t log_colors_light[8]
Definition colorscheme.h:71
char source_file[4096]
Definition colorscheme.h:75
char description[256]
Definition colorscheme.h:64
rgb_pixel_t log_colors_dark[8]
Definition colorscheme.h:67
char name[64]
Definition colorscheme.h:63
bool has_light_variant
Definition colorscheme.h:70
Compiled ANSI escape codes for a color scheme.
Definition colorscheme.h:85
Mutex type (POSIX: pthread_mutex_t with debug tracking)
RGB pixel structure.
#define PLATFORM_MAX_PATH_LENGTH
Definition system.c:69
terminal_color_mode_t
Terminal color support levels.
Definition terminal.h:578