From 789a98982eac63a02bb06fbd07a010fc2eec0e92 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 15 Sep 2023 12:33:33 +0100 Subject: Reply to SMGRAPHICS. --- image-sixel.c | 1 - input.c | 16 +++++++++++++++- screen-write.c | 2 ++ tmux.h | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/image-sixel.c b/image-sixel.c index 41170ec0..2958d20d 100644 --- a/image-sixel.c +++ b/image-sixel.c @@ -23,7 +23,6 @@ #include "tmux.h" -#define SIXEL_COLOUR_REGISTERS 1024 #define SIXEL_WIDTH_LIMIT 10000 #define SIXEL_HEIGHT_LIMIT 10000 diff --git a/input.c b/input.c index 821f029a..f49964d4 100644 --- a/input.c +++ b/input.c @@ -1839,8 +1839,22 @@ input_csi_dispatch_sm_private(struct input_ctx *ictx) /* Handle CSI graphics SM. */ static void -input_csi_dispatch_sm_graphics(__unused struct input_ctx *ictx) +input_csi_dispatch_sm_graphics(struct input_ctx *ictx) { +#ifdef ENABLE_SIXEL + int n, m, o; + + if (ictx->param_list_len > 3) + return; + n = input_get(ictx, 0, 0, 0); + m = input_get(ictx, 1, 0, 0); + o = input_get(ictx, 2, 0, 0); + + if (n == 1 && (m == 1 || m == 2 || m == 4)) + input_reply(ictx, "\033[?%d;0;%uS", n, SIXEL_COLOUR_REGISTERS); + else + input_reply(ictx, "\033[?%d;3;%dS", n, o); +#endif } /* Handle CSI window operations. */ diff --git a/screen-write.c b/screen-write.c index 8eff304d..923dac6e 100644 --- a/screen-write.c +++ b/screen-write.c @@ -1418,7 +1418,9 @@ screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped, u_int bg) struct screen *s = ctx->s; struct grid *gd = s->grid; struct grid_line *gl; +#ifdef ENABLE_SIXEL int redraw = 0; +#endif u_int rupper = s->rupper, rlower = s->rlower; gl = grid_get_line(gd, gd->hsize + s->cy); diff --git a/tmux.h b/tmux.h index f9740022..2f730842 100644 --- a/tmux.h +++ b/tmux.h @@ -3432,6 +3432,7 @@ int image_check_area(struct screen *, u_int, u_int, u_int, u_int); int image_scroll_up(struct screen *, u_int); /* image-sixel.c */ +#define SIXEL_COLOUR_REGISTERS 1024 struct sixel_image *sixel_parse(const char *, size_t, u_int, u_int); void sixel_free(struct sixel_image *); void sixel_log(struct sixel_image *); -- cgit v1.2.3