From dcebf9c7f954a55350b68d0ead1935612c4e2e05 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Thu, 15 Oct 2026 13:04:01 +0300 Subject: Rename the library to wsap_vtcore ncurses installs and defines struct term. In a file that includes both headers, an ncurses TERMINAL * and this library's terminal are silently the same type. The name wsap_vtcore avoids the clash. The public header is now . Every global symbol uses the wsap_vtcore_ prefix, every macro uses WSAP_VTCORE_, and the shared library is libwsap_vtcore.so.0. The default terminal name is now "wsap_vtcore". The ISA override variable is WSAP_VTCORE_ISA. No other behavior changes. The amalgamation writes wsap_vtcore.c and wsap_vtcore.h. Co-Authored-By: Claude Haiku 5.5 --- src/palette.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src/palette.c') diff --git a/src/palette.c b/src/palette.c index 610fe52..ab7d7a6 100644 --- a/src/palette.c +++ b/src/palette.c @@ -81,7 +81,7 @@ static inline float linf_to_srgbf(float c) : 12.92f * c; } -static const struct term_theme builtin_theme = { +static const struct wsap_vtcore_theme builtin_theme = { .fg = 0xFFFFFFFFu, .bg = 0xFF1E1E2Eu, .cursor = 0xFF89B4FAu, @@ -93,12 +93,12 @@ static const struct term_theme builtin_theme = { }, }; -void term_theme_default(struct term_theme *theme) +void wsap_vtcore_theme_default(struct wsap_vtcore_theme *theme) { *theme = builtin_theme; } -static const struct term_theme high_contrast_theme = { +static const struct wsap_vtcore_theme high_contrast_theme = { .fg = 0xFFFFFFFFu, .bg = 0xFF000000u, .cursor = 0xFF00FFFFu, @@ -110,14 +110,14 @@ static const struct term_theme high_contrast_theme = { }, }; -void term_theme_high_contrast(struct term_theme *theme) +void wsap_vtcore_theme_high_contrast(struct wsap_vtcore_theme *theme) { *theme = high_contrast_theme; } /* Finds the slot for key and the default it resets to. Keys are * foreground, background, and color0 to color15. */ -static uint32_t *palette_slot(struct term_theme *p, const char *key, +static uint32_t *palette_slot(struct wsap_vtcore_theme *p, const char *key, uint32_t *fallback) { if (!strcmp(key, "foreground")) { @@ -145,7 +145,7 @@ static uint32_t *palette_slot(struct term_theme *p, const char *key, return &p->ansi[i]; } -bool term_theme_set_key(struct term_theme *p, const char *key, const char *val) +bool wsap_vtcore_theme_set_key(struct wsap_vtcore_theme *p, const char *key, const char *val) { if (!p || !key || !val) return false; @@ -158,7 +158,7 @@ bool term_theme_set_key(struct term_theme *p, const char *key, const char *val) return true; } uint32_t v; - if (!term_color_parse(val, &v)) + if (!wsap_vtcore_color_parse(val, &v)) return false; *slot = v; return true; @@ -167,7 +167,7 @@ bool term_theme_set_key(struct term_theme *p, const char *key, const char *val) static bool parse_hex_channel(const char *s, size_t len, uint8_t *out) { if (len == 2) { - int d0 = term_hex_nib(s[0]), d1 = term_hex_nib(s[1]); + int d0 = wsap_vtcore_hex_nib(s[0]), d1 = wsap_vtcore_hex_nib(s[1]); if ((d0 | d1) < 0) return false; *out = (uint8_t)((d0 << 4) | d1); @@ -177,7 +177,7 @@ static bool parse_hex_channel(const char *s, size_t len, uint8_t *out) return false; unsigned value = 0; for (size_t i = 0; i < len; i++) { - int d = term_hex_nib(s[i]); + int d = wsap_vtcore_hex_nib(s[i]); if (d < 0) return false; value = (value << 4) | (unsigned)d; @@ -234,11 +234,11 @@ static bool parse_hex_rgb(const char *s, size_t cw, uint32_t *out) !parse_hex_channel(s + cw, cw, &g) || !parse_hex_channel(s + 2 * cw, cw, &b)) return false; - *out = term_rgb(r, g, b); + *out = wsap_vtcore_rgb(r, g, b); return true; } -bool term_color_parse(const char *input, uint32_t *out) +bool wsap_vtcore_color_parse(const char *input, uint32_t *out) { if (!input || !out) return false; @@ -294,7 +294,7 @@ bool term_color_parse(const char *input, uint32_t *out) parse_hex_channel(channels[j], chlens[j], &c[j]); if (!ok) return false; } - *out = term_rgb(c[0], c[1], c[2]); + *out = wsap_vtcore_rgb(c[0], c[1], c[2]); return true; } @@ -357,7 +357,7 @@ static uint32_t lab_to_rgb(struct lab lab) float g = linf_to_srgbf(-xf * 0.9692660f + yf * 1.8760108f + zf * 0.0415560f); float b = linf_to_srgbf(xf * 0.0556434f - yf * 0.2040259f + zf * 1.0572252f); - return term_rgb(quantize_channel(r), quantize_channel(g), quantize_channel(b)); + return wsap_vtcore_rgb(quantize_channel(r), quantize_channel(g), quantize_channel(b)); } static struct lab lab_lerp(float t, struct lab a, struct lab b) @@ -375,7 +375,7 @@ static struct lab lab_lerp(float t, struct lab a, struct lab b) * between the background, the ANSI colors, and the foreground, so they match * the theme instead of the fixed xterm values. */ -static void derive_palette(uint32_t *p, const struct term_theme *theme) +static void derive_palette(uint32_t *p, const struct wsap_vtcore_theme *theme) { struct lab base8[8]; base8[0] = lab_from_rgb(theme->bg); @@ -385,9 +385,9 @@ static void derive_palette(uint32_t *p, const struct term_theme *theme) for (int i = 0; i < 16; i++) p[i] = theme->ansi[i]; - p[TERM_PALETTE_FG] = theme->fg; - p[TERM_PALETTE_BG] = theme->bg; - p[TERM_PALETTE_CURSOR] = theme->cursor; + p[WSAP_VTCORE_PALETTE_FG] = theme->fg; + p[WSAP_VTCORE_PALETTE_BG] = theme->bg; + p[WSAP_VTCORE_PALETTE_CURSOR] = theme->cursor; bool is_light_theme = base8[7].l < base8[0].l; if (is_light_theme) { @@ -427,9 +427,9 @@ static void derive_palette(uint32_t *p, const struct term_theme *theme) } } -void term_palette_init(struct palette *p, const struct term_theme *theme) +void wsap_vtcore_palette_init(struct palette *p, const struct wsap_vtcore_theme *theme) { - static const struct term_theme zero; + static const struct wsap_vtcore_theme zero; p->theme = theme && memcmp(theme, &zero, sizeof(zero)) ? *theme : builtin_theme; if (!p->theme.cursor) p->theme.cursor = builtin_theme.cursor; @@ -438,21 +438,21 @@ void term_palette_init(struct palette *p, const struct term_theme *theme) p->version++; } -void term_palette_set(struct palette *p, int slot, uint32_t argb) +void wsap_vtcore_palette_set(struct palette *p, int slot, uint32_t argb) { - if ((unsigned)slot >= TERM_PALETTE_SIZE || p->colors[slot] == argb) + if ((unsigned)slot >= WSAP_VTCORE_PALETTE_SIZE || p->colors[slot] == argb) return; p->colors[slot] = argb; p->version++; } -void term_palette_reset(struct palette *p, int slot) +void wsap_vtcore_palette_reset(struct palette *p, int slot) { - if ((unsigned)slot < TERM_PALETTE_SIZE) - term_palette_set(p, slot, p->base[slot]); + if ((unsigned)slot < WSAP_VTCORE_PALETTE_SIZE) + wsap_vtcore_palette_set(p, slot, p->base[slot]); } -void term_palette_reset_all(struct palette *p) +void wsap_vtcore_palette_reset_all(struct palette *p) { if (memcmp(p->colors, p->base, sizeof(p->colors))) { memcpy(p->colors, p->base, sizeof(p->colors)); -- cgit v1.2.3