aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--csi.c12
-rw-r--r--main.c16
-rw-r--r--osc.c10
-rw-r--r--terminal.c2
-rw-r--r--terminal.h4
5 files changed, 19 insertions, 25 deletions
diff --git a/csi.c b/csi.c
index 9eb50dae..225d9cb0 100644
--- a/csi.c
+++ b/csi.c
@@ -105,7 +105,7 @@ csi_sgr(struct terminal *term)
case 36:
case 37:
term->vt.attrs.have_fg = 1;
- term->vt.attrs.fg = term->colors.colors256[param - 30];
+ term->vt.attrs.fg = term->colors.table[param - 30];
break;
case 38: {
@@ -114,7 +114,7 @@ csi_sgr(struct terminal *term)
{
uint8_t idx = term->vt.params.v[i + 2].value;
term->vt.attrs.have_fg = 1;
- term->vt.attrs.fg = term->colors.colors256[idx];
+ term->vt.attrs.fg = term->colors.table[idx];
i += 2;
}
@@ -168,7 +168,7 @@ csi_sgr(struct terminal *term)
case 46:
case 47:
term->vt.attrs.have_bg = 1;
- term->vt.attrs.bg = term->colors.colors256[param - 40];
+ term->vt.attrs.bg = term->colors.table[param - 40];
break;
case 48: {
@@ -177,7 +177,7 @@ csi_sgr(struct terminal *term)
{
uint8_t idx = term->vt.params.v[i + 2].value;
term->vt.attrs.have_bg = 1;
- term->vt.attrs.bg = term->colors.colors256[idx];
+ term->vt.attrs.bg = term->colors.table[idx];
i += 2;
}
@@ -230,7 +230,7 @@ csi_sgr(struct terminal *term)
case 96:
case 97:
term->vt.attrs.have_fg = 1;
- term->vt.attrs.fg = term->colors.colors256[param - 90 + 8];
+ term->vt.attrs.fg = term->colors.table[param - 90 + 8];
break;
/* Bright background colors */
@@ -243,7 +243,7 @@ csi_sgr(struct terminal *term)
case 106:
case 107:
term->vt.attrs.have_bg = 1;
- term->vt.attrs.bg = term->colors.colors256[param - 100 + 8];
+ term->vt.attrs.bg = term->colors.table[param - 100 + 8];
break;
default:
diff --git a/main.c b/main.c
index 2185dbbd..d63f4402 100644
--- a/main.c
+++ b/main.c
@@ -445,7 +445,7 @@ main(int argc, char *const *argv)
.colors = {
.default_fg = conf.colors.fg,
.default_bg = conf.colors.bg,
- .default_colors256 = {
+ .default_table = {
conf.colors.regular[0],
conf.colors.regular[1],
conf.colors.regular[2],
@@ -502,26 +502,20 @@ main(int argc, char *const *argv)
/* Initialize the 256 gray-scale color cube */
{
-#if 0 /* pick colors from term struct instead, since they can be changed runtime */
- for (size_t i = 0; i < 8; i++)
- term.colors.default_colors256[i] = term.colors.default_regular[i];
- for (size_t i = 0; i < 8; i++)
- term.colors.default_colors256[8 + i] = term.colors.default_bright[i];
-#endif
-
+ /* First 16 entries have already been initialized from conf */
for (size_t r = 0; r < 6; r++) {
for (size_t g = 0; g < 6; g++) {
for (size_t b = 0; b < 6; b++) {
- term.colors.default_colors256[16 + r * 6 * 6 + g * 6 + b]
+ term.colors.default_table[16 + r * 6 * 6 + g * 6 + b]
= r * 51 << 16 | g * 51 << 8 | b * 51;
}
}
}
for (size_t i = 0; i < 24; i++)
- term.colors.default_colors256[232 + i] = i * 11 << 16 | i * 11 << 8 | i * 11;
+ term.colors.default_table[232 + i] = i * 11 << 16 | i * 11 << 8 | i * 11;
- memcpy(term.colors.colors256, term.colors.default_colors256, sizeof(term.colors.colors256));
+ memcpy(term.colors.table, term.colors.default_table, sizeof(term.colors.table));
}
if (term.ptmx == -1) {
diff --git a/osc.c b/osc.c
index 2fd1e08f..b2f8159e 100644
--- a/osc.c
+++ b/osc.c
@@ -291,7 +291,7 @@ osc_dispatch(struct terminal *term)
/* Client queried for current value */
if (strlen(string) == 1 && string[0] == '?') {
- uint32_t color = term->colors.colors256[idx];
+ uint32_t color = term->colors.table[idx];
uint8_t r = (color >> 16) & 0xff;
uint8_t g = (color >> 8) & 0xff;
uint8_t b = (color >> 0) & 0xff;
@@ -307,7 +307,7 @@ osc_dispatch(struct terminal *term)
if (!parse_rgb(string, &color))
break;
- term->colors.colors256[idx] = color;
+ term->colors.table[idx] = color;
render_refresh(term);
break;
}
@@ -364,14 +364,14 @@ osc_dispatch(struct terminal *term)
if (strlen(string) == 0) {
for (size_t i = 0; i < 256; i++)
- term->colors.colors256[i] = term->colors.default_colors256[i];
+ term->colors.table[i] = term->colors.default_table[i];
} else {
unsigned idx = 0;
for (; *string != '\0'; string++) {
char c = *string;
if (c == ';') {
- term->colors.colors256[idx] = term->colors.default_colors256[idx];
+ term->colors.table[idx] = term->colors.default_table[idx];
idx = 0;
continue;
}
@@ -380,7 +380,7 @@ osc_dispatch(struct terminal *term)
idx += c - '0';
}
- term->colors.colors256[idx] = term->colors.default_colors256[idx];
+ term->colors.table[idx] = term->colors.default_table[idx];
}
render_refresh(term);
diff --git a/terminal.c b/terminal.c
index 593bf8ff..b80093a0 100644
--- a/terminal.c
+++ b/terminal.c
@@ -62,7 +62,7 @@ term_reset(struct terminal *term, bool hard)
term->colors.fg = term->colors.default_fg;
term->colors.bg = term->colors.default_bg;
for (size_t i = 0; i < 256; i++)
- term->colors.colors256[i] = term->colors.default_colors256[i];
+ term->colors.table[i] = term->colors.default_table[i];
term->print_needs_wrap = false;
term->cursor = (struct coord){0, 0};
term->saved_cursor = (struct coord){0, 0};
diff --git a/terminal.h b/terminal.h
index a104b897..d9c94b70 100644
--- a/terminal.h
+++ b/terminal.h
@@ -285,12 +285,12 @@ struct terminal {
struct {
uint32_t fg;
uint32_t bg;
- uint32_t colors256[256];
+ uint32_t table[256];
double alpha;
uint32_t default_fg;
uint32_t default_bg;
- uint32_t default_colors256[256];
+ uint32_t default_table[256];
} colors;
struct {