mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-12 04:27:51 -05:00
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.
This commit is contained in:
parent
462229af70
commit
80361ca04e
3 changed files with 21 additions and 7 deletions
25
sixel.c
25
sixel.c
|
|
@ -39,6 +39,8 @@ sixel_init(struct terminal *term)
|
|||
|
||||
count = 0;
|
||||
|
||||
sixel_purge_at_cursor(term);
|
||||
|
||||
/* TODO: default palette */
|
||||
}
|
||||
|
||||
|
|
@ -52,6 +54,22 @@ sixel_destroy(struct sixel *sixel)
|
|||
sixel->data = NULL;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
1
sixel.h
1
sixel.h
|
|
@ -9,6 +9,7 @@ void sixel_put(struct terminal *term, uint8_t c);
|
|||
void sixel_unhook(struct terminal *term);
|
||||
|
||||
void sixel_destroy(struct sixel *sixel);
|
||||
void sixel_purge_at_cursor(struct terminal *term);
|
||||
|
||||
void sixel_colors_report_current(struct terminal *term);
|
||||
void sixel_colors_reset(struct terminal *term);
|
||||
|
|
|
|||
|
|
@ -2128,6 +2128,8 @@ term_print(struct terminal *term, wchar_t wc, int width)
|
|||
print_linewrap(term);
|
||||
print_insert(term, width);
|
||||
|
||||
sixel_purge_at_cursor(term);
|
||||
|
||||
/* *Must* get current cell *after* linewrap+insert */
|
||||
struct row *row = term->grid->cur_row;
|
||||
struct cell *cell = &row->cells[term->cursor.point.col];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue