sixel: add sixel_reflow_grid()

This function reflows all sixels in the specified grid.

The pre-existing sixel_reflow() function is a shortcut for

  sixel_reflow_grid(term, &term->normal)
  sixel_reflow_grid(term, &term->alt);
This commit is contained in:
Daniel Eklöf 2022-10-09 16:01:11 +02:00
parent b52262da8e
commit f70c34c5a8
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 79 additions and 71 deletions

20
sixel.c
View file

@ -838,13 +838,10 @@ sixel_cell_size_changed(struct terminal *term)
} }
void void
sixel_reflow(struct terminal *term) sixel_reflow_grid(struct terminal *term, struct grid *grid)
{ {
struct grid *g = term->grid; /* Meh - the sixel functions we call use term->grid... */
struct grid *active_grid = term->grid;
for (size_t i = 0; i < 2; i++) {
struct grid *grid = i == 0 ? &term->normal : &term->alt;
term->grid = grid; term->grid = grid;
/* Need the “real” list to be empty from the beginning */ /* Need the “real” list to be empty from the beginning */
@ -914,9 +911,16 @@ sixel_reflow(struct terminal *term)
} }
tll_free(copy); tll_free(copy);
} term->grid = active_grid;
}
term->grid = g; void
sixel_reflow(struct terminal *term)
{
for (size_t i = 0; i < 2; i++) {
struct grid *grid = i == 0 ? &term->normal : &term->alt;
sixel_reflow_grid(term, grid);
}
} }
void void

View file

@ -19,6 +19,10 @@ void sixel_scroll_up(struct terminal *term, int rows);
void sixel_scroll_down(struct terminal *term, int rows); void sixel_scroll_down(struct terminal *term, int rows);
void sixel_cell_size_changed(struct terminal *term); void sixel_cell_size_changed(struct terminal *term);
void sixel_reflow_grid(struct terminal *term, struct grid *grid);
/* Shortcut for sixel_reflow_grid(normal) + sixel_reflow_grid(alt) */
void sixel_reflow(struct terminal *term); void sixel_reflow(struct terminal *term);
/* /*