diff --git a/screen.c b/screen.c index 8bfb7071..a7a13af2 100644 --- a/screen.c +++ b/screen.c @@ -91,6 +91,7 @@ screen_init(struct screen *s, u_int sx, u_int sy, u_int hlimit) #ifdef ENABLE_SIXEL TAILQ_INIT(&s->images); + TAILQ_INIT(&s->saved_images); #endif s->write_list = NULL; @@ -643,6 +644,10 @@ screen_alternate_on(struct screen *s, struct grid_cell *gc, int cursor) } memcpy(&s->saved_cell, gc, sizeof s->saved_cell); +#ifdef ENABLE_SIXEL + TAILQ_CONCAT(&s->saved_images, &s->images, entry); +#endif + grid_view_clear(s->grid, 0, 0, sx, sy, 8); s->saved_flags = s->grid->flags; @@ -697,6 +702,11 @@ screen_alternate_off(struct screen *s, struct grid_cell *gc, int cursor) grid_destroy(s->saved_grid); s->saved_grid = NULL; +#ifdef ENABLE_SIXEL + image_free_all(s); + TAILQ_CONCAT(&s->images, &s->saved_images, entry); +#endif + if (s->cx > screen_size_x(s) - 1) s->cx = screen_size_x(s) - 1; if (s->cy > screen_size_y(s) - 1) diff --git a/tmux.h b/tmux.h index 414c2819..d7ea3aad 100644 --- a/tmux.h +++ b/tmux.h @@ -984,6 +984,7 @@ struct screen { #ifdef ENABLE_SIXEL struct images images; + struct images saved_images; #endif struct screen_write_cline *write_list;