summaryrefslogtreecommitdiff
path: root/src/libsystemd-terminal/term-screen.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-10-03 14:44:41 +0200
committerDavid Herrmann <dh.herrmann@gmail.com>2014-10-03 15:57:00 +0200
commit56dec05d29098b151421625c68525c2c3961e574 (patch)
tree61dfb1b094344451c14b5e1adad9632c5631d8e8 /src/libsystemd-terminal/term-screen.c
parentcad8fe9a2b2ac340ef69233dd32e1bb1e45dae48 (diff)
terminal/screen: add color converter
Terminals use pseudo color-codes mixed with 8bit and 24bit colors. Provide a color-converter so external renderers only have to deal with ARGB32 colors. This requires a color-palette as input as there's no fixed mapping. We provide a default, but maybe we wanna support external palettes in the future.
Diffstat (limited to 'src/libsystemd-terminal/term-screen.c')
-rw-r--r--src/libsystemd-terminal/term-screen.c26
1 files changed, 2 insertions, 24 deletions
diff --git a/src/libsystemd-terminal/term-screen.c b/src/libsystemd-terminal/term-screen.c
index ccfb9a450c..3f7ef1cf3c 100644
--- a/src/libsystemd-terminal/term-screen.c
+++ b/src/libsystemd-terminal/term-screen.c
@@ -2944,31 +2944,9 @@ static int screen_SGR(term_screen *screen, const term_seq *seq) {
if (i >= seq->n_args || seq->args[i] < 0)
break;
+ dst->ccode = TERM_CCODE_256;
code = seq->args[i];
- if (code < 16) {
- dst->ccode = code;
- } else if (code < 232) {
- static const uint8_t bval[] = {
- 0x00, 0x5f, 0x87,
- 0xaf, 0xd7, 0xff,
- };
-
- dst->ccode = TERM_CCODE_256;
- dst->c256 = code;
- code -= 16;
- dst->blue = bval[code % 6];
- code /= 6;
- dst->green = bval[code % 6];
- code /= 6;
- dst->red = bval[code % 6];
- } else if (code < 256) {
- dst->ccode = TERM_CCODE_256;
- dst->c256 = code;
- code = (code - 232) * 10 + 8;
- dst->red = code;
- dst->green = code;
- dst->blue = code;
- }
+ dst->c256 = code < 256 ? code : 0;
break;
}