mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-14 04:27:57 -05:00
sixel: destroy all sixels when font size is decreased
If changing the font size causes the cell size to decrease, either horizontally or vertically (or both), then delete all sixels since the grid space they allocated no longer is enough to hold the images.
This commit is contained in:
parent
2c4ebec4da
commit
8f5e6e85e0
4 changed files with 37 additions and 1 deletions
|
|
@ -38,6 +38,7 @@
|
|||
scrollback.
|
||||
* Mouse cursor from `hand2` to `left_ptr` when client is capturing the
|
||||
mouse.
|
||||
* Sixel images are now removed when the font size is **decreased**.
|
||||
|
||||
|
||||
### Deprecated
|
||||
|
|
|
|||
11
sixel.c
11
sixel.c
|
|
@ -66,6 +66,17 @@ sixel_destroy(struct sixel *sixel)
|
|||
sixel->data = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
sixel_destroy_all(struct terminal *term)
|
||||
{
|
||||
tll_foreach(term->normal.sixel_images, it)
|
||||
sixel_destroy(&it->item);
|
||||
tll_foreach(term->alt.sixel_images, it)
|
||||
sixel_destroy(&it->item);
|
||||
tll_free(term->normal.sixel_images);
|
||||
tll_free(term->alt.sixel_images);
|
||||
}
|
||||
|
||||
static void
|
||||
sixel_erase(struct terminal *term, struct sixel *sixel)
|
||||
{
|
||||
|
|
|
|||
1
sixel.h
1
sixel.h
|
|
@ -11,6 +11,7 @@ void sixel_put(struct terminal *term, uint8_t c);
|
|||
void sixel_unhook(struct terminal *term);
|
||||
|
||||
void sixel_destroy(struct sixel *sixel);
|
||||
void sixel_destroy_all(struct terminal *term);
|
||||
|
||||
/*
|
||||
* Deletes all sixels that are touched by the specified row(s). Used
|
||||
|
|
|
|||
25
terminal.c
25
terminal.c
|
|
@ -1423,7 +1423,30 @@ term_font_size_adjust(struct terminal *term, double amount)
|
|||
return false;
|
||||
}
|
||||
|
||||
term_set_fonts(term, (struct fcft_font *[]){data[0].font_out, data[1].font_out, data[2].font_out, data[3].font_out});
|
||||
const int old_cell_width = term->cell_width;
|
||||
const int old_cell_height = term->cell_height;
|
||||
|
||||
if (!term_set_fonts(term, (struct fcft_font *[]){data[0].font_out, data[1].font_out, data[2].font_out, data[3].font_out}))
|
||||
return false;
|
||||
|
||||
if (term->cell_width < old_cell_width ||
|
||||
term->cell_height < old_cell_height)
|
||||
{
|
||||
/*
|
||||
* The cell size has decreased.
|
||||
*
|
||||
* This means sixels, which we cannot resize, no longer fit
|
||||
* into their "allocated" grid space.
|
||||
*
|
||||
* To be able to fit them, we would have to change the grid
|
||||
* content. Inserting empty lines _might_ seem acceptable, but
|
||||
* we'd also need to insert empty columns, which would break
|
||||
* existing layout completely.
|
||||
*
|
||||
* So we delete them.
|
||||
*/
|
||||
sixel_destroy_all(term);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue