commit 75b0dec
uint
·
2026-07-14 12:49:38 +0000 UTC
parent de3c8a7
use color_table from config
3 files changed,
+23,
-24
+5,
-5
1@@ -18,11 +18,11 @@ static const int pad_y = 8;
2 static const char* shell = NULL; /* NULL uses $SHELL */
3 static const char* term_name = "vt100";
4
5-/* Colors Format: 0xAARRGGBB */
6-static const uint32_t default_fg = 0xffdcdccc;
7-static const uint32_t default_bg = 0xff111111;
8-static const uint32_t cursor_fg = 0xff111111;
9-static const uint32_t cursor_bg = 0xffdcdccc;
10+/* AARRGGBB */
11+static const uint32_t default_fg = 0xffffffff;
12+static const uint32_t default_bg = 0xff000000;
13+static const uint32_t cursor_fg = 0xff000000;
14+static const uint32_t cursor_bg = 0xffffffff;
15
16 static const uint32_t color_table[16] = {
17 0xff000000, /* black */
+9,
-4
1@@ -45,8 +45,8 @@ static Term term = {
2 .rows = 0,
3 .ptyfd = -1,
4 .ptypid = -1,
5- .fg = TERM_DEFAULT_FG,
6- .bg = TERM_DEFAULT_BG,
7+ .fg = default_fg,
8+ .bg = default_bg,
9 .cursor_visible = true,
10 };
11
12@@ -321,8 +321,13 @@ static void run(void)
13 bool cursor = term.cursor_visible &&
14 x == car.x && y == car.y;
15 bool reverse = (r->attr & TERM_ATTR_REVERSE) != 0;
16- uint32_t fg = (cursor != reverse) ? r->bg : r->fg;
17- uint32_t bg = (cursor != reverse) ? r->fg : r->bg;
18+ uint32_t fg = reverse ? r->bg : r->fg;
19+ uint32_t bg = reverse ? r->fg : r->bg;
20+
21+ if (cursor) {
22+ fg = cursor_fg;
23+ bg = cursor_bg;
24+ }
25
26 if (!r->dmg)
27 continue;
+9,
-15
1@@ -5,6 +5,7 @@
2
3 #include <grapheme.h>
4
5+#include "config.h"
6 #include "term.h"
7 #include "utils.h"
8
9@@ -26,13 +27,6 @@ static void sgr(Term* t);
10 static void utf8_flush(Term* t, Caret* c);
11 static void utf8_putc(Term* t, Caret* c, unsigned char ch);
12
13-static const uint32_t ansi_colours[16] = {
14- 0xff000000, 0xffcd0000, 0xff00cd00, 0xffcdcd00,
15- 0xff0000ee, 0xffcd00cd, 0xff00cdcd, 0xffe5e5e5,
16- 0xff7f7f7f, 0xffff0000, 0xff00ff00, 0xffffff00,
17- 0xff5c5cff, 0xffff00ff, 0xff00ffff, 0xffffffff,
18-};
19-
20 /** TODO
21 */
22 static uint32_t acs_map(unsigned char ch)
23@@ -450,8 +444,8 @@ static void sgr(Term* t)
24 int p = t->csi_params[i];
25
26 if (p == 0) {
27- t->fg = TERM_DEFAULT_FG;
28- t->bg = TERM_DEFAULT_BG;
29+ t->fg = default_fg;
30+ t->bg = default_bg;
31 t->attr = 0;
32 }
33 else if (p == 7)
34@@ -459,17 +453,17 @@ static void sgr(Term* t)
35 else if (p == 27)
36 t->attr &= ~TERM_ATTR_REVERSE; /* turn off reverse attribute bit */
37 else if (p >= 30 && p <= 37)
38- t->fg = ansi_colours[p - 30];
39+ t->fg = color_table[p - 30];
40 else if (p >= 40 && p <= 47)
41- t->bg = ansi_colours[p - 40];
42+ t->bg = color_table[p - 40];
43 else if (p >= 90 && p <= 97)
44- t->fg = ansi_colours[p - 90 + 8];
45+ t->fg = color_table[p - 90 + 8];
46 else if (p >= 100 && p <= 107)
47- t->bg = ansi_colours[p - 100 + 8];
48+ t->bg = color_table[p - 100 + 8];
49 else if (p == 39)
50- t->fg = TERM_DEFAULT_FG;
51+ t->fg = default_fg;
52 else if (p == 49)
53- t->bg = TERM_DEFAULT_BG;
54+ t->bg = default_bg;
55 else if ((p == 38 || p == 48) &&
56 i + 4 <= t->csi_idx && t->csi_params[i + 1] == 2) {
57 uint32_t col = rgba(