Merge branch 'obsd-master' into master

pull/3079/head
Thomas Adam 2022-02-15 16:01:11 +00:00
commit 85ef73591d
7 changed files with 61 additions and 10 deletions

View File

@ -225,7 +225,7 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
}
if (args_has(args, 'l')) {
tty_putcode_ptr2(&tc->tty, TTYC_MS, "", "?");
tty_send_osc52_query(&tc->tty);
return (CMD_RETURN_NORMAL);
}

View File

@ -2235,15 +2235,19 @@ input_enter_dcs(struct input_ctx *ictx)
static int
input_dcs_dispatch(struct input_ctx *ictx)
{
struct window_pane *wp = ictx->wp;
struct screen_write_ctx *sctx = &ictx->ctx;
u_char *buf = ictx->input_buf;
size_t len = ictx->input_len;
const char prefix[] = "tmux;";
const u_int prefixlen = (sizeof prefix) - 1;
if (wp == NULL)
return (0);
if (ictx->flags & INPUT_DISCARD)
return (0);
if (!options_get_number(ictx->wp->options, "allow-passthrough"))
return (0);
log_debug("%s: \"%s\"", __func__, buf);
if (len >= prefixlen && strncmp(buf, prefix, prefixlen) == 0)

View File

@ -301,7 +301,7 @@ const struct options_table_entry options_table[] = {
.choices = options_table_extended_keys_list,
.default_num = 0,
.text = "Whether to request extended key sequences from terminals "
"that support it."
"that support it."
},
{ .name = "focus-events",
@ -800,6 +800,14 @@ const struct options_table_entry options_table[] = {
"linked to ('off')."
},
{ .name = "allow-passthrough",
.type = OPTIONS_TABLE_FLAG,
.scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE,
.default_num = 0,
.text = "Whether applications are allowed to use the escape sequence "
"to bypass tmux."
},
{ .name = "allow-rename",
.type = OPTIONS_TABLE_FLAG,
.scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE,
@ -988,7 +996,7 @@ const struct options_table_entry options_table[] = {
.choices = options_table_pane_border_lines_list,
.default_num = PANE_LINES_SINGLE,
.text = "Type of characters used to draw pane border lines. Some of "
"these are only supported on terminals with UTF-8 support."
"these are only supported on terminals with UTF-8 support."
},
{ .name = "pane-border-status",
@ -1040,7 +1048,7 @@ const struct options_table_entry options_table[] = {
.choices = options_table_popup_border_lines_list,
.default_num = BOX_LINES_SINGLE,
.text = "Type of characters used to draw popup border lines. Some of "
"these are only supported on terminals with UTF-8 support."
"these are only supported on terminals with UTF-8 support."
},
{ .name = "remain-on-exit",
@ -1170,7 +1178,7 @@ const struct options_table_entry options_table[] = {
.scope = OPTIONS_TABLE_WINDOW,
.default_num = 1,
.text = "Whether xterm-style function key sequences should be sent. "
"This option is no longer used."
"This option is no longer used."
},
/* Hook options. */
@ -1218,8 +1226,8 @@ const struct options_table_entry options_table[] = {
OPTIONS_TABLE_HOOK("client-active", ""),
OPTIONS_TABLE_HOOK("client-attached", ""),
OPTIONS_TABLE_HOOK("client-detached", ""),
OPTIONS_TABLE_HOOK("client-focus-in", ""),
OPTIONS_TABLE_HOOK("client-focus-out", ""),
OPTIONS_TABLE_HOOK("client-focus-in", ""),
OPTIONS_TABLE_HOOK("client-focus-out", ""),
OPTIONS_TABLE_HOOK("client-resized", ""),
OPTIONS_TABLE_HOOK("client-session-changed", ""),
OPTIONS_TABLE_PANE_HOOK("pane-died", ""),

7
tmux.1
View File

@ -4406,6 +4406,13 @@ The default is on.
Available pane options are:
.Pp
.Bl -tag -width Ds -compact
.It Xo Ic allow-passthrough
.Op Ic on | off
.Xc
Allow programs in the pane to bypass
.Nm
using a terminal escape sequence (\eePtmux;...\ee\e\e).
.Pp
.It Xo Ic allow-rename
.Op Ic on | off
.Xc

4
tmux.h
View File

@ -1278,6 +1278,7 @@ LIST_HEAD(tty_terms, tty_term);
struct tty {
struct client *client;
struct event start_timer;
struct event query_timer;
u_int sx;
u_int sy;
@ -1321,7 +1322,7 @@ struct tty {
#define TTY_NOBLOCK 0x8
#define TTY_STARTED 0x10
#define TTY_OPENED 0x20
/* 0x40 unused */
#define TTY_OSC52QUERY 0x40
#define TTY_BLOCK 0x80
#define TTY_HAVEDA 0x100
#define TTY_HAVEXDA 0x200
@ -2174,6 +2175,7 @@ void tty_reset(struct tty *);
void tty_region_off(struct tty *);
void tty_margin_off(struct tty *);
void tty_cursor(struct tty *, u_int, u_int);
void tty_send_osc52_query(struct tty *);
void tty_putcode(struct tty *, enum tty_code_code);
void tty_putcode1(struct tty *, enum tty_code_code, int);
void tty_putcode2(struct tty *, enum tty_code_code, int, int);

View File

@ -1217,6 +1217,11 @@ tty_keys_clipboard(__unused struct tty *tty, const char *buf, size_t len,
buf++;
end--;
/* If we did not request this, ignore it. */
if (~tty->flags & TTY_OSC52QUERY)
return (0);
tty->flags &= ~TTY_OSC52QUERY;
/* It has to be a string so copy it. */
copy = xmalloc(end + 1);
memcpy(copy, buf, end);

27
tty.c
View File

@ -83,6 +83,8 @@ static void tty_check_overlay_range(struct tty *, u_int, u_int, u_int,
#define TTY_BLOCK_START(tty) (1 + ((tty)->sx * (tty)->sy) * 8)
#define TTY_BLOCK_STOP(tty) (1 + ((tty)->sx * (tty)->sy) / 8)
#define TTY_QUERY_TIMEOUT 5
void
tty_create_log(void)
{
@ -307,7 +309,7 @@ tty_start_tty(struct tty *tty)
{
struct client *c = tty->client;
struct termios tio;
struct timeval tv = { .tv_sec = 3 };
struct timeval tv = { .tv_sec = TTY_QUERY_TIMEOUT };
setblocking(c->fd, 0);
event_add(&tty->event_in, NULL);
@ -2917,3 +2919,26 @@ tty_default_attributes(struct tty *tty, const struct grid_cell *defaults,
gc.bg = bg;
tty_attributes(tty, &gc, defaults, palette);
}
static void
tty_query_timer_callback(__unused int fd, __unused short events, void *data)
{
struct tty *tty = data;
tty->flags &= ~TTY_OSC52QUERY;
}
void
tty_send_osc52_query(struct tty *tty)
{
struct timeval tv = { .tv_sec = TTY_QUERY_TIMEOUT };
if ((~tty->flags & TTY_STARTED) || (tty->flags & TTY_OSC52QUERY))
return;
tty_putcode_ptr2(tty, TTYC_MS, "", "?");
tty->flags |= TTY_OSC52QUERY;
evtimer_set(&tty->query_timer, tty_query_timer_callback, tty);
evtimer_add(&tty->query_timer, &tv);
}