mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-15 22:05:24 -05:00
sixel: implement reflow
Move sixel reflow from grid_reflow() to sixel_reflow(). This lets us use internal sixel functions to update the sixels. Note that grid_reflow() still needs to remap the sixelss coordinates.
This commit is contained in:
parent
660d6a06eb
commit
2e7afc615c
3 changed files with 51 additions and 54 deletions
48
sixel.c
48
sixel.c
|
|
@ -508,6 +508,54 @@ sixel_cell_size_changed(struct terminal *term)
|
|||
term->grid = g;
|
||||
}
|
||||
|
||||
void
|
||||
sixel_reflow(struct terminal *term)
|
||||
{
|
||||
struct grid *g = term->grid;
|
||||
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
struct grid *grid = i == 0 ? &term->normal : &term->alt;
|
||||
|
||||
term->grid = grid;
|
||||
|
||||
/* Need the “real” list to be empty from the beginning */
|
||||
tll(struct sixel) copy = tll_init();
|
||||
tll_foreach(grid->sixel_images, it)
|
||||
tll_push_back(copy, it->item);
|
||||
tll_free(grid->sixel_images);
|
||||
|
||||
tll_rforeach(copy, it) {
|
||||
struct sixel *six = &it->item;
|
||||
int start = six->pos.row;
|
||||
int end = (start + six->rows - 1) & (grid->num_rows - 1);
|
||||
|
||||
if (end < start) {
|
||||
/* Crosses scrollback wrap-around */
|
||||
/* TOOD: split image */
|
||||
sixel_destroy(six);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (six->rows > grid->num_rows) {
|
||||
/* Image too large */
|
||||
/* TODO: keep bottom part? */
|
||||
sixel_destroy(six);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Sixels that didn’t overlap may now do so, which isn’t
|
||||
* allowed of course */
|
||||
_sixel_overwrite_by_rectangle(
|
||||
term, six->pos.row, six->pos.col, six->rows, six->cols);
|
||||
sixel_insert(term, it->item);
|
||||
}
|
||||
|
||||
tll_free(copy);
|
||||
}
|
||||
|
||||
term->grid = g;
|
||||
}
|
||||
|
||||
void
|
||||
sixel_unhook(struct terminal *term)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue