aboutsummaryrefslogtreecommitdiff
path: root/csi.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-30 16:03:03 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-30 16:03:03 +0000
commit85ef9df586dfca22d16d04c9777dc38ff896223a (patch)
tree0cc74665440e259460bed9a4aff48c9c69b4bb12 /csi.c
parentwip: initial multithreaded renderer (diff)
render: add a 'clean' bit to each cell; only render cells that aren't clean
This patch takes a bit from the foreground color value in a cell (todo: split up foreground/background into bitfields with a separate field for 'foreground/background' has been set), and only re-renders cells that aren't marked as clean. Note: we use a 'clean' bit rather than a 'dirty' bit to make it easy to erase cells - we can (keep doing) do that by simply memsetting a cell range to 0.
Diffstat (limited to 'csi.c')
-rw-r--r--csi.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/csi.c b/csi.c
index 5f37663c..a82f03f3 100644
--- a/csi.c
+++ b/csi.c
@@ -126,7 +126,7 @@ csi_sgr(struct terminal *term)
case 35:
case 36:
case 37:
- term->vt.attrs.foreground = 1 << 31 | term->colors.regular[param - 30];
+ term->vt.attrs.foreground = 1 << 30 | term->colors.regular[param - 30];
break;
case 38: {
@@ -141,7 +141,7 @@ csi_sgr(struct terminal *term)
color = term->colors.bright[idx - 8];
else
color = colors256[idx];
- term->vt.attrs.foreground = 1 << 31 | color;
+ term->vt.attrs.foreground = 1 << 30 | color;
i += 2;
}
@@ -152,7 +152,7 @@ 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 << 31 | r << 16 | g << 8 | b;
+ term->vt.attrs.foreground = 1 << 30 | r << 16 | g << 8 | b;
i += 4;
}
@@ -168,7 +168,7 @@ csi_sgr(struct terminal *term)
/* 6 - CS tolerance */
/* 7 - color space associated with tolerance */
- term->vt.attrs.foreground = 1 << 31 | r << 16 | g << 8 | b;
+ term->vt.attrs.foreground = 1 << 30 | r << 16 | g << 8 | b;
} else {
LOG_ERR("invalid CSI SGR sequence");
abort();
@@ -195,7 +195,7 @@ csi_sgr(struct terminal *term)
case 45:
case 46:
case 47:
- term->vt.attrs.background = 1 << 31 | term->colors.regular[param - 40];
+ term->vt.attrs.background = 1 << 30 | term->colors.regular[param - 40];
break;
case 48: {
@@ -211,7 +211,7 @@ csi_sgr(struct terminal *term)
color = term->colors.bright[idx - 8];
else
color = colors256[idx];
- term->vt.attrs.background = 1 << 31 | color;
+ term->vt.attrs.background = 1 << 30 | color;
i += 2;
}
@@ -221,7 +221,7 @@ 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 << 31 | r << 16 | g << 8 | b;
+ term->vt.attrs.background = 1 << 30 | r << 16 | g << 8 | b;
i += 4;
}
@@ -238,7 +238,7 @@ csi_sgr(struct terminal *term)
/* 6 - CS tolerance */
/* 7 - color space associated with tolerance */
- term->vt.attrs.background = 1 << 31 | r << 16 | g << 8 | b;
+ term->vt.attrs.background = 1 << 30 | r << 16 | g << 8 | b;
} else {
LOG_ERR("invalid CSI SGR sequence");
abort();
@@ -265,7 +265,7 @@ csi_sgr(struct terminal *term)
case 95:
case 96:
case 97:
- term->vt.attrs.foreground = 1 << 31 | term->colors.bright[param - 90];
+ term->vt.attrs.foreground = 1 << 30 | term->colors.bright[param - 90];
break;
/* Regular background colors */
@@ -277,7 +277,7 @@ csi_sgr(struct terminal *term)
case 105:
case 106:
case 107:
- term->vt.attrs.background = 1 << 31 | term->colors.bright[param - 100];
+ term->vt.attrs.background = 1 << 30 | term->colors.bright[param - 100];
break;
default:
@@ -487,6 +487,9 @@ csi_dispatch(struct terminal *term, uint8_t final)
memmove(&term->grid->cur_row->cells[term->cursor.col],
&term->grid->cur_row->cells[term->cursor.col + count],
remaining * sizeof(term->grid->cur_row->cells[0]));
+
+ for (size_t c = 0; c < remaining; c++)
+ term->grid->cur_row->cells[term->cursor.col + c].attrs.clean = 0;
term->grid->cur_row->dirty = true;
/* Erase the remainder of the line */
@@ -511,6 +514,8 @@ csi_dispatch(struct terminal *term, uint8_t final)
memmove(&term->grid->cur_row->cells[term->cursor.col + count],
&term->grid->cur_row->cells[term->cursor.col],
remaining * sizeof(term->grid->cur_row->cells[0]));
+ for (size_t c = 0; c < remaining; c++)
+ term->grid->cur_row->cells[term->cursor.col + count + c].attrs.clean = 0;
term->grid->cur_row->dirty = true;
/* Erase (insert space characters) */