aboutsummaryrefslogtreecommitdiff
path: root/csi.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-08-02 16:19:07 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-08-02 16:19:07 +0000
commit4d7993b36fa3f97e26c527c37b36eb9321b79791 (patch)
tree391b9125d821de5010b5f383813135882d54293d /csi.c
parentterm: implement reset (diff)
cell: pack more efficiently and store glyph as a wchar
The 'attributes' struct is now 8 bytes and naturally packed (used to be 9 bytes, artificially packed). 'cell' struct is now 12 bytes, naturally packed (used to be 13 bytes, artificially packed). Furthermore, the glyph is stored as a wchar instead of a char*. This makes it easier (faster) to do glyph lookup when rendering.
Diffstat (limited to 'csi.c')
-rw-r--r--csi.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/csi.c b/csi.c
index 03f80ccc..8eb57de9 100644
--- a/csi.c
+++ b/csi.c
@@ -50,8 +50,8 @@ static void
sgr_reset(struct terminal *term)
{
memset(&term->vt.attrs, 0, sizeof(term->vt.attrs));
- term->vt.attrs.foreground = term->colors.fg;
- term->vt.attrs.background = term->colors.bg;
+ term->vt.attrs.fg = term->colors.fg;
+ term->vt.attrs.bg = term->colors.bg;
}
static const char *
@@ -129,7 +129,8 @@ csi_sgr(struct terminal *term)
case 35:
case 36:
case 37:
- term->vt.attrs.foreground = 1 << 30 | term->colors.regular[param - 30];
+ term->vt.attrs.have_fg = 1;
+ term->vt.attrs.fg = term->colors.regular[param - 30];
break;
case 38: {
@@ -144,7 +145,8 @@ csi_sgr(struct terminal *term)
color = term->colors.bright[idx - 8];
else
color = colors256[idx];
- term->vt.attrs.foreground = 1 << 30 | color;
+ term->vt.attrs.have_fg = 1;
+ term->vt.attrs.fg = color;
i += 2;
}
@@ -155,7 +157,8 @@ csi_sgr(struct terminal *term)
uint8_t r = term->vt.params.v[i + 2].value;
uint8_t g = term->vt.params.v[i + 3].value;
uint8_t b = term->vt.params.v[i + 4].value;
- term->vt.attrs.foreground = 1 << 30 | r << 16 | g << 8 | b;
+ term->vt.attrs.have_fg = 1;
+ term->vt.attrs.fg = r << 16 | g << 8 | b;
i += 4;
}
@@ -171,7 +174,8 @@ csi_sgr(struct terminal *term)
/* 6 - CS tolerance */
/* 7 - color space associated with tolerance */
- term->vt.attrs.foreground = 1 << 30 | r << 16 | g << 8 | b;
+ term->vt.attrs.have_fg = 1;
+ term->vt.attrs.fg = r << 16 | g << 8 | b;
} else
UNHANDLED_SGR();
}
@@ -183,7 +187,7 @@ csi_sgr(struct terminal *term)
}
case 39:
- term->vt.attrs.foreground = 0;
+ term->vt.attrs.have_fg = 0;
break;
/* Regular background colors */
@@ -195,7 +199,8 @@ csi_sgr(struct terminal *term)
case 45:
case 46:
case 47:
- term->vt.attrs.background = 1 << 30 | term->colors.regular[param - 40];
+ term->vt.attrs.have_bg = 1;
+ term->vt.attrs.bg = term->colors.regular[param - 40];
break;
case 48: {
@@ -211,7 +216,8 @@ csi_sgr(struct terminal *term)
color = term->colors.bright[idx - 8];
else
color = colors256[idx];
- term->vt.attrs.background = 1 << 30 | color;
+ term->vt.attrs.have_bg = 1;
+ term->vt.attrs.bg = color;
i += 2;
}
@@ -221,7 +227,8 @@ csi_sgr(struct terminal *term)
uint8_t r = term->vt.params.v[i + 2].value;
uint8_t g = term->vt.params.v[i + 3].value;
uint8_t b = term->vt.params.v[i + 4].value;
- term->vt.attrs.background = 1 << 30 | r << 16 | g << 8 | b;
+ term->vt.attrs.have_bg = 1;
+ term->vt.attrs.bg = r << 16 | g << 8 | b;
i += 4;
}
@@ -238,7 +245,8 @@ csi_sgr(struct terminal *term)
/* 6 - CS tolerance */
/* 7 - color space associated with tolerance */
- term->vt.attrs.background = 1 << 30 | r << 16 | g << 8 | b;
+ term->vt.attrs.have_bg = 1;
+ term->vt.attrs.bg = r << 16 | g << 8 | b;
} else
UNHANDLED_SGR();
}
@@ -249,7 +257,7 @@ csi_sgr(struct terminal *term)
break;
}
case 49:
- term->vt.attrs.background = 0;
+ term->vt.attrs.have_bg = 0;
break;
/* Bright foreground colors */
@@ -261,7 +269,8 @@ csi_sgr(struct terminal *term)
case 95:
case 96:
case 97:
- term->vt.attrs.foreground = 1 << 30 | term->colors.bright[param - 90];
+ term->vt.attrs.have_fg = 1;
+ term->vt.attrs.fg = term->colors.bright[param - 90];
break;
/* Regular background colors */
@@ -273,7 +282,8 @@ csi_sgr(struct terminal *term)
case 105:
case 106:
case 107:
- term->vt.attrs.background = 1 << 30 | term->colors.bright[param - 100];
+ term->vt.attrs.have_bg = 1;
+ term->vt.attrs.bg = term->colors.bright[param - 100];
break;
default: