From 631e0c0870d98a4b3f97c90a8f3d07d549fdf8fb Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Wed, 21 Aug 2019 18:47:48 +0200 Subject: 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. --- csi.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'csi.c') diff --git a/csi.c b/csi.c index 52772e7d..9eb50dae 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.regular[param - 30]; + term->vt.attrs.fg = term->colors.colors256[param - 30]; break; case 38: { @@ -113,15 +113,8 @@ csi_sgr(struct terminal *term) term->vt.params.v[i + 1].value == 5) { uint8_t idx = term->vt.params.v[i + 2].value; - uint32_t color; - if (idx < 8) - color = term->colors.regular[idx]; - else if (idx < 16) - color = term->colors.bright[idx - 8]; - else - color = term->colors.colors256[idx]; term->vt.attrs.have_fg = 1; - term->vt.attrs.fg = color; + term->vt.attrs.fg = term->colors.colors256[idx]; i += 2; } @@ -175,7 +168,7 @@ csi_sgr(struct terminal *term) case 46: case 47: term->vt.attrs.have_bg = 1; - term->vt.attrs.bg = term->colors.regular[param - 40]; + term->vt.attrs.bg = term->colors.colors256[param - 40]; break; case 48: { @@ -183,16 +176,8 @@ csi_sgr(struct terminal *term) term->vt.params.v[i + 1].value == 5) { uint8_t idx = term->vt.params.v[i + 2].value; - uint32_t color; - - if (idx < 8) - color = term->colors.regular[idx]; - else if (idx < 16) - color = term->colors.bright[idx - 8]; - else - color = term->colors.colors256[idx]; term->vt.attrs.have_bg = 1; - term->vt.attrs.bg = color; + term->vt.attrs.bg = term->colors.colors256[idx]; i += 2; } @@ -245,10 +230,10 @@ csi_sgr(struct terminal *term) case 96: case 97: term->vt.attrs.have_fg = 1; - term->vt.attrs.fg = term->colors.bright[param - 90]; + term->vt.attrs.fg = term->colors.colors256[param - 90 + 8]; break; - /* Regular background colors */ + /* Bright background colors */ case 100: case 101: case 102: @@ -258,7 +243,7 @@ csi_sgr(struct terminal *term) case 106: case 107: term->vt.attrs.have_bg = 1; - term->vt.attrs.bg = term->colors.bright[param - 100]; + term->vt.attrs.bg = term->colors.colors256[param - 100 + 8]; break; default: -- cgit v1.3