aboutsummaryrefslogtreecommitdiff
path: root/osc.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-08-21 16:47:48 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-08-21 16:47:48 +0000
commit631e0c0870d98a4b3f97c90a8f3d07d549fdf8fb (patch)
tree9de02fa30d0ff9fe42e794ea4a036cc472726601 /osc.c
parentosc: fix indexing into 'bright' color array (diff)
term: use colors256 array for *all* colors
That is, remove the 'regular' and 'bright' color arrays. This is possible since the 256-color array is defined such that the first 16 colors map to the regular and bright colors.
Diffstat (limited to 'osc.c')
-rw-r--r--osc.c34
1 files changed, 5 insertions, 29 deletions
diff --git a/osc.c b/osc.c
index 64ea481d..2fd1e08f 100644
--- a/osc.c
+++ b/osc.c
@@ -291,11 +291,7 @@ osc_dispatch(struct terminal *term)
/* Client queried for current value */
if (strlen(string) == 1 && string[0] == '?') {
- uint32_t color =
- (idx >= 0 && idx < 8) ? term->colors.regular[idx] :
- (idx >= 8 && idx < 16) ? term->colors.bright[idx - 8] :
- term->colors.colors256[idx];
-
+ uint32_t color = term->colors.colors256[idx];
uint8_t r = (color >> 16) & 0xff;
uint8_t g = (color >> 8) & 0xff;
uint8_t b = (color >> 0) & 0xff;
@@ -311,13 +307,7 @@ osc_dispatch(struct terminal *term)
if (!parse_rgb(string, &color))
break;
- if (idx >= 0 && idx < 8)
- term->colors.regular[idx] = color;
- else if (idx >= 8 && idx < 16)
- term->colors.bright[idx - 8] = color;
- else
- term->colors.colors256[idx] = color;
-
+ term->colors.colors256[idx] = color;
render_refresh(term);
break;
}
@@ -373,11 +363,7 @@ osc_dispatch(struct terminal *term)
/* Reset Color Number 'c' (whole table if no parameter) */
if (strlen(string) == 0) {
- for (size_t i = 0; i < 8; i++) {
- term->colors.regular[i] = term->colors.default_regular[i];
- term->colors.bright[i] = term->colors.default_bright[i];
- }
- for (size_t i = 16; i < 256; i++)
+ for (size_t i = 0; i < 256; i++)
term->colors.colors256[i] = term->colors.default_colors256[i];
} else {
unsigned idx = 0;
@@ -385,12 +371,7 @@ osc_dispatch(struct terminal *term)
for (; *string != '\0'; string++) {
char c = *string;
if (c == ';') {
- if (idx >= 0 && idx < 8)
- term->colors.regular[idx] = term->colors.default_regular[idx];
- else if (idx >= 8 && idx < 16)
- term->colors.bright[idx - 8] = term->colors.default_bright[idx - 8];
- else if (idx < 256)
- term->colors.colors256[idx] = term->colors.default_colors256[idx];
+ term->colors.colors256[idx] = term->colors.default_colors256[idx];
idx = 0;
continue;
}
@@ -399,12 +380,7 @@ osc_dispatch(struct terminal *term)
idx += c - '0';
}
- if (idx >= 0 && idx < 8)
- term->colors.regular[idx] = term->colors.default_regular[idx];
- else if (idx >= 8 && idx < 16)
- term->colors.bright[idx - 8] = term->colors.default_bright[idx - 8];
- else if (idx < 256)
- term->colors.colors256[idx] = term->colors.default_colors256[idx];
+ term->colors.colors256[idx] = term->colors.default_colors256[idx];
}
render_refresh(term);