summaryrefslogtreecommitdiff
path: root/src/palette.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/palette.c')
-rw-r--r--src/palette.c50
1 files changed, 25 insertions, 25 deletions
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));