aboutsummaryrefslogtreecommitdiff
path: root/sixel.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-03-13 17:44:23 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-03-13 17:47:16 +0000
commitd482bf0a304b8224499bf9de9e0781518106ec7c (patch)
treeafc68b49ecaa21a3f1d5a089cfa5a7b18a95d654 /sixel.c
parentinput: maximize: unset fullscreen before toggling maximized state (diff)
sixel: improve handling of images when reflowing the grids
Update the sixels' 'row' attribute when re-flowing a grid, to ensure it is rendered at the correct place. This should work in most cases, but will break when the cell size has changed (e.g. font size increase/decrease, or a DPI change). This patch also moves the sixel image list from the terminal struct into the grid struct. The sixels are per-grid after all.
Diffstat (limited to 'sixel.c')
-rw-r--r--sixel.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/sixel.c b/sixel.c
index 90d886fe..98a82deb 100644
--- a/sixel.c
+++ b/sixel.c
@@ -76,22 +76,19 @@ sixel_erase(struct terminal *term, struct sixel *sixel)
void
sixel_delete_at_row(struct terminal *term, int _row)
{
- if (likely(tll_length(term->sixel_images) == 0))
+ if (likely(tll_length(term->grid->sixel_images) == 0))
return;
- tll_foreach(term->sixel_images, it) {
+ tll_foreach(term->grid->sixel_images, it) {
struct sixel *six = &it->item;
- if (six->grid != term->grid)
- continue;
-
const int row = (term->grid->offset + _row) & (term->grid->num_rows - 1);
const int six_start = six->pos.row;
const int six_end = six_start + six->rows - 1;
if (row >= six_start && row <= six_end) {
sixel_erase(term, six);
- tll_remove(term->sixel_images, it);
+ tll_remove(term->grid->sixel_images, it);
}
}
}
@@ -101,18 +98,15 @@ sixel_delete_in_range(struct terminal *term, int _start, int _end)
{
assert(_end >= _start);
- if (likely(tll_length(term->sixel_images) == 0))
+ if (likely(tll_length(term->grid->sixel_images) == 0))
return;
if (_start == _end)
return sixel_delete_at_row(term, _start);
- tll_foreach(term->sixel_images, it) {
+ tll_foreach(term->grid->sixel_images, it) {
struct sixel *six = &it->item;
- if (six->grid != term->grid)
- continue;
-
const int start = (term->grid->offset + _start) & (term->grid->num_rows - 1);
const int end = start + (_end - _start);
const int six_start = six->pos.row;
@@ -123,7 +117,7 @@ sixel_delete_in_range(struct terminal *term, int _start, int _end)
(start >= six_start && end <= six_end)) /* Fully within sixel range */
{
sixel_erase(term, six);
- tll_remove(term->sixel_images, it);
+ tll_remove(term->grid->sixel_images, it);
}
}
}
@@ -147,7 +141,6 @@ sixel_unhook(struct terminal *term)
.width = term->sixel.image.width,
.height = term->sixel.image.height,
.rows = (term->sixel.image.height + term->cell_height - 1) / term->cell_height,
- .grid = term->grid,
.pos = (struct coord){
term->cursor.point.col,
(term->grid->offset + term->cursor.point.row) & (term->grid->num_rows - 1)},
@@ -172,7 +165,7 @@ sixel_unhook(struct terminal *term)
term_formfeed(term);
render_refresh(term);
- tll_push_back(term->sixel_images, image);
+ tll_push_back(term->grid->sixel_images, image);
}
static unsigned