summaryrefslogtreecommitdiffstats
path: root/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'input.c')
-rw-r--r--input.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/input.c b/input.c
index b833b50e..eb421b28 100644
--- a/input.c
+++ b/input.c
@@ -1446,7 +1446,11 @@ input_csi_dispatch(struct input_ctx *ictx)
case -1:
break;
case 0:
+#ifdef ENABLE_SIXEL
+ input_reply(ictx, "\033[?1;2;4c");
+#else
input_reply(ictx, "\033[?1;2c");
+#endif
break;
default:
log_debug("%s: unknown '%c'", __func__, ictx->ch);
@@ -1835,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. */
@@ -2280,14 +2298,27 @@ input_dcs_dispatch(struct input_ctx *ictx)
const char prefix[] = "tmux;";
const u_int prefixlen = (sizeof prefix) - 1;
long long allow_passthrough = 0;
+#ifdef ENABLE_SIXEL
+ struct window *w;
+ struct sixel_image *si;
+#endif
if (wp == NULL)
return (0);
+
if (ictx->flags & INPUT_DISCARD) {
log_debug("%s: %zu bytes (discard)", __func__, len);
return (0);
}
- log_debug("%s: %zu bytes", __func__, len);
+
+#ifdef ENABLE_SIXEL
+ w = wp->window;
+ if (buf[0] == 'q') {
+ si = sixel_parse(buf, len, w->xpixel, w->ypixel);
+ if (si != NULL)
+ screen_write_sixelimage(sctx, si, ictx->cell.cell.bg);
+ }
+#endif
allow_passthrough = options_get_number(wp->options, "allow-passthrough");
if (!allow_passthrough)