aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-03-07 10:22:08 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-03-11 16:32:57 +0000
commit1c9c1aafc892a50300f3cfc81c06d107fbe6d840 (patch)
treec6693e563205c5cb0b94a78196fb6c11f942cd74
parentsixel: resize: check new width/height against max geometry early (diff)
sixel: adjust image height when processing ‘-’
-rw-r--r--sixel.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/sixel.c b/sixel.c
index 9b68391c..4807f2a8 100644
--- a/sixel.c
+++ b/sixel.c
@@ -921,23 +921,20 @@ sixel_add(struct terminal *term, uint32_t color, uint8_t sixel)
{
//LOG_DBG("adding sixel %02hhx using color 0x%06x", sixel, color);
- int height = term->sixel.image.height;
int width = term->sixel.image.width;
- if (term->sixel.pos.col >= width ||
- term->sixel.pos.row >= height)
- {
+ if (term->sixel.pos.col >= width) {
width = max(
term->sixel.image.width,
max(term->sixel.max_col, term->sixel.pos.col + 1));
- height = max(
- term->sixel.image.height, term->sixel.pos.row + 6);
-
- if (!resize(term, width, height))
+ if (!resize(term, width, term->sixel.image.height))
return;
}
+ /* Height adjustment done while processing ‘-’ */
+ xassert(term->sixel.pos.row < term->sixel.image.height);
+
size_t ofs = term->sixel.row_byte_ofs + term->sixel.pos.col;
uint32_t *data = term->sixel.image.data;
@@ -985,6 +982,9 @@ decsixel(struct terminal *term, uint8_t c)
term->sixel.pos.row += 6;
term->sixel.pos.col = 0;
term->sixel.row_byte_ofs += term->sixel.image.width * 6;
+
+ if (term->sixel.pos.row >= term->sixel.image.height)
+ resize(term, term->sixel.image.width, term->sixel.pos.row + 6);
break;
case '?': case '@': case 'A': case 'B': case 'C': case 'D': case 'E':