mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
term: update sixel rows/cols *after* cell dimension change, *before* resize
This fixes an issue where we resized+reflowed with bad rows/cols values in the sixels.
This commit is contained in:
parent
9102194846
commit
892730e5b9
1 changed files with 27 additions and 39 deletions
66
terminal.c
66
terminal.c
|
|
@ -605,12 +605,38 @@ term_set_fonts(struct terminal *term, struct fcft_font *fonts[static 4])
|
|||
term->fonts[i] = fonts[i];
|
||||
}
|
||||
|
||||
const int old_cell_width = term->cell_width;
|
||||
const int old_cell_height = term->cell_height;
|
||||
|
||||
term->cell_width = term->fonts[0]->space_advance.x > 0
|
||||
? term->fonts[0]->space_advance.x : term->fonts[0]->max_advance.x;
|
||||
term->cell_height = max(term->fonts[0]->height,
|
||||
term->fonts[0]->ascent + term->fonts[0]->descent);
|
||||
LOG_INFO("cell width=%d, height=%d", term->cell_width, term->cell_height);
|
||||
|
||||
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);
|
||||
} else if (term->cell_width != old_cell_width ||
|
||||
term->cell_height != old_cell_height)
|
||||
{
|
||||
sixel_cell_size_changed(term);
|
||||
}
|
||||
|
||||
/* Use force, since cell-width/height may have changed */
|
||||
render_resize_force(term, term->width / term->scale, term->height / term->scale);
|
||||
return true;
|
||||
|
|
@ -1503,45 +1529,7 @@ term_font_size_adjust(struct terminal *term, double amount)
|
|||
term->font_sizes[i].px_size = -1;
|
||||
}
|
||||
|
||||
const int old_cell_width = term->cell_width;
|
||||
const int old_cell_height = term->cell_height;
|
||||
|
||||
if (!reload_fonts(term))
|
||||
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);
|
||||
} else if (term->cell_width != old_cell_width ||
|
||||
term->cell_height != old_cell_height)
|
||||
{
|
||||
tll_foreach(term->normal.sixel_images, it) {
|
||||
struct sixel *six = &it->item;
|
||||
six->rows = (six->height + term->cell_height - 1) / term->cell_height;
|
||||
six->cols = (six->width + term->cell_width - 1) / term->cell_width;
|
||||
}
|
||||
|
||||
tll_foreach(term->alt.sixel_images, it) {
|
||||
struct sixel *six = &it->item;
|
||||
six->rows = (six->height + term->cell_height - 1) / term->cell_height;
|
||||
six->cols = (six->width + term->cell_width - 1) / term->cell_width;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return reload_fonts(term);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue