mirror of
https://github.com/tmux/tmux.git
synced 2025-01-05 23:38:48 +00:00
Store SIXELs as a box for the moment.
This commit is contained in:
parent
5d8dbcdf3d
commit
b1904c9b8d
@ -1676,7 +1676,21 @@ screen_write_rawstring(struct screen_write_ctx *ctx, u_char *str, u_int len)
|
||||
void
|
||||
screen_write_sixelimage(struct screen_write_ctx *ctx, struct sixel_image *si)
|
||||
{
|
||||
struct tty_ctx ttyctx;
|
||||
struct tty_ctx ttyctx;
|
||||
struct screen *s = ctx->s, *image;
|
||||
u_int sx = screen_size_x(s), sy = screen_size_y(s);
|
||||
|
||||
image = sixel_to_screen(si);
|
||||
if (image == NULL)
|
||||
return;
|
||||
|
||||
sx = sx - s->cx;
|
||||
if (sx > screen_size_x(image))
|
||||
sx = screen_size_x(image);
|
||||
sy = sy - s->cx;
|
||||
if (sy > screen_size_x(image))
|
||||
sy = screen_size_x(image);
|
||||
screen_write_fast_copy(ctx, image, 0, 0, sx, sy);
|
||||
|
||||
screen_write_initctx(ctx, &ttyctx);
|
||||
ttyctx.ptr = si;
|
||||
|
34
sixel.c
34
sixel.c
@ -517,3 +517,37 @@ sixel_print(struct sixel_image *si, struct sixel_image *map, size_t *size)
|
||||
free(contains);
|
||||
return (buf);
|
||||
}
|
||||
|
||||
struct screen *
|
||||
sixel_to_screen(struct sixel_image *si)
|
||||
{
|
||||
struct screen *s;
|
||||
struct screen_write_ctx ctx;
|
||||
struct grid_cell gc;
|
||||
u_int x, y, sx, sy;
|
||||
|
||||
sixel_size_in_cells(si, &sx, &sy);
|
||||
|
||||
s = xmalloc(sizeof *s);
|
||||
screen_init(s, sx, sy, 0);
|
||||
|
||||
memcpy(&gc, &grid_default_cell, sizeof gc);
|
||||
gc.attr |= (GRID_ATTR_CHARSET|GRID_ATTR_DIM);
|
||||
utf8_set(&gc.data, '~');
|
||||
|
||||
screen_write_start(&ctx, NULL, s);
|
||||
if (sx == 1 || sy == 1) {
|
||||
for (y = 0; y < sy; y++) {
|
||||
for (x = 0; x < sx; x++)
|
||||
grid_view_set_cell(s->grid, x, y, &gc);
|
||||
}
|
||||
} else {
|
||||
screen_write_box(&ctx, sx, sy);
|
||||
for (y = 1; y < sy - 1; y++) {
|
||||
for (x = 1; x < sx - 1; x++)
|
||||
grid_view_set_cell(s->grid, x, y, &gc);
|
||||
}
|
||||
}
|
||||
screen_write_stop(&ctx);
|
||||
return (s);
|
||||
}
|
||||
|
1
tmux.h
1
tmux.h
@ -2714,5 +2714,6 @@ struct sixel_image *sixel_scale(struct sixel_image *, u_int, u_int, u_int,
|
||||
u_int, u_int, u_int);
|
||||
char *sixel_print(struct sixel_image *, struct sixel_image *,
|
||||
size_t *);
|
||||
struct screen *sixel_to_screen(struct sixel_image *);
|
||||
|
||||
#endif /* TMUX_H */
|
||||
|
6
tty.c
6
tty.c
@ -1884,8 +1884,10 @@ tty_cmd_sixelimage(struct tty *tty, const struct tty_ctx *ctx)
|
||||
u_int cx = s->cx, cy = s->cy, sx, sy;
|
||||
u_int i, j, x, y, rx, ry;
|
||||
|
||||
if ((~flags & TERM_SIXEL) && tty_term_has(tty->term, TTYC_SXL))
|
||||
if ((~flags & TERM_SIXEL) && !tty_term_has(tty->term, TTYC_SXL)) {
|
||||
wp->flags |= PANE_REDRAW;
|
||||
return;
|
||||
}
|
||||
if (tty->xpixel == 0 || tty->ypixel == 0)
|
||||
return;
|
||||
|
||||
@ -1906,6 +1908,8 @@ tty_cmd_sixelimage(struct tty *tty, const struct tty_ctx *ctx)
|
||||
data = sixel_print(new, si, &size);
|
||||
if (data != NULL) {
|
||||
log_debug("%s: %zu bytes: %s", __func__, size, data);
|
||||
tty_region_off(tty);
|
||||
tty_margin_off(tty);
|
||||
tty_cursor(tty, x, y);
|
||||
|
||||
tty->flags |= TTY_NOBLOCK;
|
||||
|
Loading…
Reference in New Issue
Block a user