aboutsummaryrefslogtreecommitdiff
path: root/sixel.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-02-22 20:35:45 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-02-22 20:35:45 +0000
commit80361ca04e12b65396d27fa1d981f6739861e453 (patch)
treeb5cf4c80bd3f8e1da30031410c64ac4d29290cb1 /sixel.c
parentsixel: oops (diff)
sixel: purge images at current cursor row
When printing a character, or starting a new sixel image, purge all images that cover the cursor's current row.
Diffstat (limited to 'sixel.c')
-rw-r--r--sixel.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/sixel.c b/sixel.c
index 7d31dea4..db87844e 100644
--- a/sixel.c
+++ b/sixel.c
@@ -39,6 +39,8 @@ sixel_init(struct terminal *term)
count = 0;
+ sixel_purge_at_cursor(term);
+
/* TODO: default palette */
}
@@ -53,6 +55,22 @@ sixel_destroy(struct sixel *sixel)
}
void
+sixel_purge_at_cursor(struct terminal *term)
+{
+ const int row = term->grid->offset + term->cursor.point.row;
+
+ tll_foreach(term->sixel_images, it) {
+ const int start = it->item.pos.row;
+ const int end = start + it->item.rows;
+
+ if (row >= start && row < end) {
+ sixel_destroy(&it->item);
+ tll_remove(term->sixel_images, it);
+ }
+ }
+}
+
+void
sixel_unhook(struct terminal *term)
{
free(term->sixel.palette);
@@ -74,13 +92,6 @@ sixel_unhook(struct terminal *term)
term->sixel.image.data,
term->sixel.image.width * sizeof(uint32_t));
- tll_foreach(term->sixel_images, it) {
- if (it->item.pos.row == image.pos.row) {
- sixel_destroy(&it->item);
- tll_remove(term->sixel_images, it);
- }
- }
-
tll_push_back(term->sixel_images, image);
term->sixel.image.data = NULL;