Save and restore images in alternate screen, GitHub issue 3732.

This commit is contained in:
Nicholas Marriott
2025-11-12 07:49:17 +00:00
parent 33cfe8b809
commit c77d49f67e
2 changed files with 11 additions and 0 deletions

View File

@@ -91,6 +91,7 @@ screen_init(struct screen *s, u_int sx, u_int sy, u_int hlimit)
#ifdef ENABLE_SIXEL #ifdef ENABLE_SIXEL
TAILQ_INIT(&s->images); TAILQ_INIT(&s->images);
TAILQ_INIT(&s->saved_images);
#endif #endif
s->write_list = NULL; 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); 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); grid_view_clear(s->grid, 0, 0, sx, sy, 8);
s->saved_flags = s->grid->flags; 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); grid_destroy(s->saved_grid);
s->saved_grid = NULL; 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) if (s->cx > screen_size_x(s) - 1)
s->cx = screen_size_x(s) - 1; s->cx = screen_size_x(s) - 1;
if (s->cy > screen_size_y(s) - 1) if (s->cy > screen_size_y(s) - 1)

1
tmux.h
View File

@@ -984,6 +984,7 @@ struct screen {
#ifdef ENABLE_SIXEL #ifdef ENABLE_SIXEL
struct images images; struct images images;
struct images saved_images;
#endif #endif
struct screen_write_cline *write_list; struct screen_write_cline *write_list;