mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-19 05:33:44 -04:00
sixel: wip: maintain a list of finished, and "active" sixel images
In unhook, add the generated image to a list of finished sixel images, along with positioning and size information. When rendering, loop this list of images, and render the images (or parts of) that are visible. When scrolling, check if any part of the images cover the re-cycled lines, and if so, remove the *entire* image from the list. This means we have the following limitations: * The renderer always renders the whole (visible area of) the image(s). There are times when this isn't necessary - for example, when the image is scrolled inside the visible area. * It would be nice if we could crop the image when parts of it is scrolled out.
This commit is contained in:
parent
f81bdfeed5
commit
f0fc82f098
4 changed files with 122 additions and 38 deletions
39
terminal.c
39
terminal.c
|
|
@ -740,6 +740,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl,
|
|||
.lower_fd = delay_lower_fd,
|
||||
.upper_fd = delay_upper_fd,
|
||||
},
|
||||
.sixel_images = tll_init(),
|
||||
.hold_at_exit = conf->hold_at_exit,
|
||||
.shutdown_cb = shutdown_cb,
|
||||
.shutdown_data = shutdown_data,
|
||||
|
|
@ -993,6 +994,12 @@ term_destroy(struct terminal *term)
|
|||
tll_free(term->ptmx_buffer);
|
||||
tll_free(term->tab_stops);
|
||||
|
||||
tll_foreach(term->sixel_images, it) {
|
||||
pixman_image_unref(it->item.pix);
|
||||
free(it->item.data);
|
||||
}
|
||||
tll_free(term->sixel_images);
|
||||
|
||||
free(term->foot_exe);
|
||||
free(term->cwd);
|
||||
|
||||
|
|
@ -1521,6 +1528,21 @@ term_scroll_partial(struct terminal *term, struct scroll_region region, int rows
|
|||
erase_line(term, grid_row_and_alloc(term->grid, r));
|
||||
if (selection_on_row_in_view(term, r))
|
||||
selection_cancel(term);
|
||||
|
||||
|
||||
tll_foreach(term->sixel_images, it) {
|
||||
/* Make it simple - remove the entire image if it starts
|
||||
* getting scrolled out */
|
||||
|
||||
int img_top_row = it->item.pos.row & (term->grid->num_rows - 1);
|
||||
int new_row = (term->grid->offset + r) & (term->grid->num_rows - 1);
|
||||
|
||||
if (img_top_row == new_row) {
|
||||
pixman_image_unref(it->item.pix);
|
||||
free(it->item.data);
|
||||
tll_remove(term->sixel_images, it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
term_damage_scroll(term, DAMAGE_SCROLL, region, rows);
|
||||
|
|
@ -1572,6 +1594,23 @@ term_scroll_reverse_partial(struct terminal *term,
|
|||
erase_line(term, grid_row_and_alloc(term->grid, r));
|
||||
if (selection_on_row_in_view(term, r))
|
||||
selection_cancel(term);
|
||||
|
||||
tll_foreach(term->sixel_images, it) {
|
||||
/* Make it simple - remove the entire image if it starts
|
||||
* getting scrolled out */
|
||||
|
||||
/* TODO: untested */
|
||||
|
||||
int img_rows = (it->item.height + term->cell_height - 1) / term->cell_height;
|
||||
int img_bottom_row = (it->item.pos.row + img_rows) & (term->grid->num_rows - 1);
|
||||
int new_row = (term->grid->offset + r) & (term->grid->num_rows - 1);
|
||||
|
||||
if (img_bottom_row == new_row) {
|
||||
pixman_image_unref(it->item.pix);
|
||||
free(it->item.data);
|
||||
tll_remove(term->sixel_images, it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
term_damage_scroll(term, DAMAGE_SCROLL_REVERSE, region, rows);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue