flag (not used yet), from Anindya Mukherjee.
-/* $OpenBSD: input.c,v 1.211 2022/10/28 13:00:02 nicm Exp $ */
+/* $OpenBSD: input.c,v 1.212 2022/11/11 08:37:55 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
if (ictx->flags & INPUT_DISCARD)
return (0);
- log_debug("%s: '%c' \"%s\" \"%s\"",
- __func__, ictx->ch, ictx->interm_buf, ictx->param_buf);
+ log_debug("%s: '%c' \"%s\" \"%s\"", __func__, ictx->ch,
+ ictx->interm_buf, ictx->param_buf);
if (input_split(ictx) != 0)
return (0);
-.\" $OpenBSD: tmux.1,v 1.907 2022/11/11 08:27:17 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.908 2022/11/11 08:37:55 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
Supports the DECFRA rectangle fill escape sequence.
.It RGB
Supports RGB colour with the SGR escape sequences.
+.It sixel
+Supports SIXEL graphics.
.It strikethrough
Supports the strikethrough SGR escape sequence.
.It sync
The sequence is terminated using the standard
.Em fsl
capability.
+.It Em \&Sxl
+Indicates that the terminal supports SIXEL.
.It Em \&Sync
Start (parameter is 1) or end (parameter is 2) a synchronized update.
.It Em \&Tc
-/* $OpenBSD: tmux.h,v 1.1184 2022/11/01 09:54:13 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1185 2022/11/11 08:37:55 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
TTYC_SMUL,
TTYC_SMULX,
TTYC_SMXX,
+ TTYC_SXL,
TTYC_SS,
TTYC_SWD,
TTYC_SYNC,
#define TERM_DECFRA 0x8
#define TERM_RGBCOLOURS 0x10
#define TERM_VT100LIKE 0x20
+#define TERM_SIXEL 0x40
int flags;
LIST_ENTRY(tty_term) entry;
#define TTY_OPENED 0x20
#define TTY_OSC52QUERY 0x40
#define TTY_BLOCK 0x80
-#define TTY_HAVEDA 0x100
+#define TTY_HAVEDA 0x100 /* Primary DA. */
#define TTY_HAVEXDA 0x200
#define TTY_SYNCING 0x400
+#define TTY_HAVEDA2 0x800 /* Seconday DA. */
int flags;
struct tty_term *term;
-/* $OpenBSD: tty-features.c,v 1.26 2022/08/15 08:41:13 nicm Exp $ */
+/* $OpenBSD: tty-features.c,v 1.27 2022/11/11 08:37:55 nicm Exp $ */
/*
* Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
0
};
+/* Terminal has sixel capability. */
+static const char *const tty_feature_sixel_capabilities[] = {
+ "Sxl",
+ NULL
+};
+static const struct tty_feature tty_feature_sixel = {
+ "sixel",
+ tty_feature_sixel_capabilities,
+ 0
+};
+
/* Available terminal features. */
static const struct tty_feature *const tty_features[] = {
&tty_feature_256,
&tty_feature_overline,
&tty_feature_rectfill,
&tty_feature_rgb,
+ &tty_feature_sixel,
&tty_feature_strikethrough,
&tty_feature_sync,
&tty_feature_title,
-/* $OpenBSD: tty-keys.c,v 1.160 2022/11/02 07:36:07 nicm Exp $ */
+/* $OpenBSD: tty-keys.c,v 1.161 2022/11/11 08:37:55 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
size_t *);
static int tty_keys_device_attributes(struct tty *, const char *, size_t,
size_t *);
+static int tty_keys_device_attributes2(struct tty *, const char *, size_t,
+ size_t *);
static int tty_keys_extended_device_attributes(struct tty *, const char *,
size_t, size_t *);
goto partial_key;
}
- /* Is this a device attributes response? */
+ /* Is this a primary device attributes response? */
switch (tty_keys_device_attributes(tty, buf, len, &size)) {
case 0: /* yes */
key = KEYC_UNKNOWN;
goto partial_key;
}
+ /* Is this a secondary device attributes response? */
+ switch (tty_keys_device_attributes2(tty, buf, len, &size)) {
+ case 0: /* yes */
+ key = KEYC_UNKNOWN;
+ goto complete_key;
+ case -1: /* no, or not valid */
+ break;
+ case 1: /* partial */
+ goto partial_key;
+ }
+
/* Is this an extended device attributes response? */
switch (tty_keys_extended_device_attributes(tty, buf, len, &size)) {
case 0: /* yes */
}
/*
- * Handle secondary device attributes input. Returns 0 for success, -1 for
+ * Handle primary device attributes input. Returns 0 for success, -1 for
* failure, 1 for partial.
*/
static int
{
struct client *c = tty->client;
u_int i, n = 0;
- char tmp[64], *endptr, p[32] = { 0 }, *cp, *next;
+ char tmp[128], *endptr, p[32] = { 0 }, *cp, *next;
*size = 0;
if (tty->flags & TTY_HAVEDA)
return (-1);
- /*
- * First three bytes are always \033[>. Some older Terminal.app
- * versions respond as for DA (\033[?) so accept and ignore that.
- */
+ /* First three bytes are always \033[?. */
if (buf[0] != '\033')
return (-1);
if (len == 1)
return (-1);
if (len == 2)
return (1);
- if (buf[2] != '>' && buf[2] != '?')
+ if (buf[2] != '?')
return (-1);
if (len == 3)
return (1);
/* Copy the rest up to a 'c'. */
- for (i = 0; i < (sizeof tmp) - 1; i++) {
+ for (i = 0; i < (sizeof tmp); i++) {
if (3 + i == len)
return (1);
if (buf[3 + i] == 'c')
break;
tmp[i] = buf[3 + i];
}
- if (i == (sizeof tmp) - 1)
+ if (i == (sizeof tmp))
return (-1);
tmp[i] = '\0';
*size = 4 + i;
- /* Ignore DA response. */
- if (buf[2] == '?')
- return (0);
+ /* Convert all arguments to numbers. */
+ cp = tmp;
+ while ((next = strsep(&cp, ";")) != NULL) {
+ p[n] = strtoul(next, &endptr, 10);
+ if (*endptr != '\0')
+ p[n] = 0;
+ if (++n == nitems(p))
+ break;
+ }
+
+ /* Add terminal features. */
+ switch (p[0]) {
+ case 62: /* VT220 */
+ case 63: /* VT320 */
+ case 64: /* VT420 */
+ for (i = 1; i < n; i++) {
+ log_debug("%s: DA feature: %d", c->name, p[i]);
+ if (p[i] == 4)
+ tty->term->flags |= TERM_SIXEL;
+ }
+ break;
+ }
+ log_debug("%s: received primary DA %.*s", c->name, (int)*size, buf);
+
+ tty_update_features(tty);
+ tty->flags |= TTY_HAVEDA;
+
+ return (0);
+}
+
+/*
+ * Handle secondary device attributes input. Returns 0 for success, -1 for
+ * failure, 1 for partial.
+ */
+static int
+tty_keys_device_attributes2(struct tty *tty, const char *buf, size_t len,
+ size_t *size)
+{
+ struct client *c = tty->client;
+ u_int i, n = 0;
+ char tmp[128], *endptr, p[32] = { 0 }, *cp, *next;
+
+ *size = 0;
+ if (tty->flags & TTY_HAVEDA2)
+ return (-1);
+
+ /* First three bytes are always \033[>. */
+ if (buf[0] != '\033')
+ return (-1);
+ if (len == 1)
+ return (1);
+ if (buf[1] != '[')
+ return (-1);
+ if (len == 2)
+ return (1);
+ if (buf[2] != '>')
+ return (-1);
+ if (len == 3)
+ return (1);
+
+ /* Copy the rest up to a 'c'. */
+ for (i = 0; i < (sizeof tmp); i++) {
+ if (3 + i == len)
+ return (1);
+ if (buf[3 + i] == 'c')
+ break;
+ tmp[i] = buf[3 + i];
+ }
+ if (i == (sizeof tmp))
+ return (-1);
+ tmp[i] = '\0';
+ *size = 4 + i;
/* Convert all arguments to numbers. */
cp = tmp;
p[n] = strtoul(next, &endptr, 10);
if (*endptr != '\0')
p[n] = 0;
- n++;
+ if (++n == nitems(p))
+ break;
}
/* Add terminal features. */
log_debug("%s: received secondary DA %.*s", c->name, (int)*size, buf);
tty_update_features(tty);
- tty->flags |= TTY_HAVEDA;
+ tty->flags |= TTY_HAVEDA2;
return (0);
}
-/* $OpenBSD: tty-term.c,v 1.94 2022/08/15 08:54:03 nicm Exp $ */
+/* $OpenBSD: tty-term.c,v 1.95 2022/11/11 08:37:55 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
[TTYC_SETRGBF] = { TTYCODE_STRING, "setrgbf" },
[TTYC_SETULC] = { TTYCODE_STRING, "Setulc" },
[TTYC_SE] = { TTYCODE_STRING, "Se" },
+ [TTYC_SXL] = { TTYCODE_FLAG, "Sxl" },
[TTYC_SGR0] = { TTYCODE_STRING, "sgr0" },
[TTYC_SITM] = { TTYCODE_STRING, "sitm" },
[TTYC_SMACS] = { TTYCODE_STRING, "smacs" },
-/* $OpenBSD: tty.c,v 1.424 2022/08/15 08:54:03 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.425 2022/11/11 08:37:55 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
struct client *c = tty->client;
log_debug("%s: start timer fired", c->name);
- if ((tty->flags & (TTY_HAVEDA|TTY_HAVEXDA)) == 0)
+ if ((tty->flags & (TTY_HAVEDA|TTY_HAVEDA2|TTY_HAVEXDA)) == 0)
tty_update_features(tty);
- tty->flags |= (TTY_HAVEDA|TTY_HAVEXDA);
+ tty->flags |= (TTY_HAVEDA|TTY_HAVEDA2|TTY_HAVEXDA);
}
void
return;
if (tty->term->flags & TERM_VT100LIKE) {
- if (~tty->flags & TTY_HAVEDA)
+ if (~tty->term->flags & TTY_HAVEDA)
+ tty_puts(tty, "\033[c");
+ if (~tty->flags & TTY_HAVEDA2)
tty_puts(tty, "\033[>c");
if (~tty->flags & TTY_HAVEXDA)
tty_puts(tty, "\033[>q");
} else
- tty->flags |= (TTY_HAVEDA|TTY_HAVEXDA);
+ tty->flags |= (TTY_HAVEDA|TTY_HAVEDA2|TTY_HAVEXDA);
}
void