mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-17 05:33:52 -04:00
term: rename colors256 -> table
This commit is contained in:
parent
631e0c0870
commit
d8fb80ea32
5 changed files with 19 additions and 25 deletions
12
csi.c
12
csi.c
|
|
@ -105,7 +105,7 @@ csi_sgr(struct terminal *term)
|
||||||
case 36:
|
case 36:
|
||||||
case 37:
|
case 37:
|
||||||
term->vt.attrs.have_fg = 1;
|
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;
|
break;
|
||||||
|
|
||||||
case 38: {
|
case 38: {
|
||||||
|
|
@ -114,7 +114,7 @@ csi_sgr(struct terminal *term)
|
||||||
{
|
{
|
||||||
uint8_t idx = term->vt.params.v[i + 2].value;
|
uint8_t idx = term->vt.params.v[i + 2].value;
|
||||||
term->vt.attrs.have_fg = 1;
|
term->vt.attrs.have_fg = 1;
|
||||||
term->vt.attrs.fg = term->colors.colors256[idx];
|
term->vt.attrs.fg = term->colors.table[idx];
|
||||||
i += 2;
|
i += 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -168,7 +168,7 @@ csi_sgr(struct terminal *term)
|
||||||
case 46:
|
case 46:
|
||||||
case 47:
|
case 47:
|
||||||
term->vt.attrs.have_bg = 1;
|
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;
|
break;
|
||||||
|
|
||||||
case 48: {
|
case 48: {
|
||||||
|
|
@ -177,7 +177,7 @@ csi_sgr(struct terminal *term)
|
||||||
{
|
{
|
||||||
uint8_t idx = term->vt.params.v[i + 2].value;
|
uint8_t idx = term->vt.params.v[i + 2].value;
|
||||||
term->vt.attrs.have_bg = 1;
|
term->vt.attrs.have_bg = 1;
|
||||||
term->vt.attrs.bg = term->colors.colors256[idx];
|
term->vt.attrs.bg = term->colors.table[idx];
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -230,7 +230,7 @@ csi_sgr(struct terminal *term)
|
||||||
case 96:
|
case 96:
|
||||||
case 97:
|
case 97:
|
||||||
term->vt.attrs.have_fg = 1;
|
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;
|
break;
|
||||||
|
|
||||||
/* Bright background colors */
|
/* Bright background colors */
|
||||||
|
|
@ -243,7 +243,7 @@ csi_sgr(struct terminal *term)
|
||||||
case 106:
|
case 106:
|
||||||
case 107:
|
case 107:
|
||||||
term->vt.attrs.have_bg = 1;
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
16
main.c
16
main.c
|
|
@ -445,7 +445,7 @@ main(int argc, char *const *argv)
|
||||||
.colors = {
|
.colors = {
|
||||||
.default_fg = conf.colors.fg,
|
.default_fg = conf.colors.fg,
|
||||||
.default_bg = conf.colors.bg,
|
.default_bg = conf.colors.bg,
|
||||||
.default_colors256 = {
|
.default_table = {
|
||||||
conf.colors.regular[0],
|
conf.colors.regular[0],
|
||||||
conf.colors.regular[1],
|
conf.colors.regular[1],
|
||||||
conf.colors.regular[2],
|
conf.colors.regular[2],
|
||||||
|
|
@ -502,26 +502,20 @@ main(int argc, char *const *argv)
|
||||||
|
|
||||||
/* Initialize the 256 gray-scale color cube */
|
/* Initialize the 256 gray-scale color cube */
|
||||||
{
|
{
|
||||||
#if 0 /* pick colors from term struct instead, since they can be changed runtime */
|
/* First 16 entries have already been initialized from conf */
|
||||||
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
|
|
||||||
|
|
||||||
for (size_t r = 0; r < 6; r++) {
|
for (size_t r = 0; r < 6; r++) {
|
||||||
for (size_t g = 0; g < 6; g++) {
|
for (size_t g = 0; g < 6; g++) {
|
||||||
for (size_t b = 0; b < 6; b++) {
|
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;
|
= r * 51 << 16 | g * 51 << 8 | b * 51;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < 24; i++)
|
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) {
|
if (term.ptmx == -1) {
|
||||||
|
|
|
||||||
10
osc.c
10
osc.c
|
|
@ -291,7 +291,7 @@ osc_dispatch(struct terminal *term)
|
||||||
|
|
||||||
/* Client queried for current value */
|
/* Client queried for current value */
|
||||||
if (strlen(string) == 1 && string[0] == '?') {
|
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 r = (color >> 16) & 0xff;
|
||||||
uint8_t g = (color >> 8) & 0xff;
|
uint8_t g = (color >> 8) & 0xff;
|
||||||
uint8_t b = (color >> 0) & 0xff;
|
uint8_t b = (color >> 0) & 0xff;
|
||||||
|
|
@ -307,7 +307,7 @@ osc_dispatch(struct terminal *term)
|
||||||
if (!parse_rgb(string, &color))
|
if (!parse_rgb(string, &color))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
term->colors.colors256[idx] = color;
|
term->colors.table[idx] = color;
|
||||||
render_refresh(term);
|
render_refresh(term);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -364,14 +364,14 @@ osc_dispatch(struct terminal *term)
|
||||||
|
|
||||||
if (strlen(string) == 0) {
|
if (strlen(string) == 0) {
|
||||||
for (size_t i = 0; i < 256; i++)
|
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 {
|
} else {
|
||||||
unsigned idx = 0;
|
unsigned idx = 0;
|
||||||
|
|
||||||
for (; *string != '\0'; string++) {
|
for (; *string != '\0'; string++) {
|
||||||
char c = *string;
|
char c = *string;
|
||||||
if (c == ';') {
|
if (c == ';') {
|
||||||
term->colors.colors256[idx] = term->colors.default_colors256[idx];
|
term->colors.table[idx] = term->colors.default_table[idx];
|
||||||
idx = 0;
|
idx = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -380,7 +380,7 @@ osc_dispatch(struct terminal *term)
|
||||||
idx += c - '0';
|
idx += c - '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
term->colors.colors256[idx] = term->colors.default_colors256[idx];
|
term->colors.table[idx] = term->colors.default_table[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
render_refresh(term);
|
render_refresh(term);
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ term_reset(struct terminal *term, bool hard)
|
||||||
term->colors.fg = term->colors.default_fg;
|
term->colors.fg = term->colors.default_fg;
|
||||||
term->colors.bg = term->colors.default_bg;
|
term->colors.bg = term->colors.default_bg;
|
||||||
for (size_t i = 0; i < 256; i++)
|
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->print_needs_wrap = false;
|
||||||
term->cursor = (struct coord){0, 0};
|
term->cursor = (struct coord){0, 0};
|
||||||
term->saved_cursor = (struct coord){0, 0};
|
term->saved_cursor = (struct coord){0, 0};
|
||||||
|
|
|
||||||
|
|
@ -285,12 +285,12 @@ struct terminal {
|
||||||
struct {
|
struct {
|
||||||
uint32_t fg;
|
uint32_t fg;
|
||||||
uint32_t bg;
|
uint32_t bg;
|
||||||
uint32_t colors256[256];
|
uint32_t table[256];
|
||||||
double alpha;
|
double alpha;
|
||||||
|
|
||||||
uint32_t default_fg;
|
uint32_t default_fg;
|
||||||
uint32_t default_bg;
|
uint32_t default_bg;
|
||||||
uint32_t default_colors256[256];
|
uint32_t default_table[256];
|
||||||
} colors;
|
} colors;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue