mirror of
https://github.com/tmux/tmux.git
synced 2026-03-06 07:45:35 +00:00
Merge branch 'obsd-master'
This commit is contained in:
43
input.c
43
input.c
@@ -1139,11 +1139,9 @@ input_get(struct input_ctx *ictx, u_int validx, int minval, int defval)
|
||||
static void
|
||||
input_send_reply(struct input_ctx *ictx, const char *reply)
|
||||
{
|
||||
struct bufferevent *bev = ictx->event;
|
||||
|
||||
if (bev != NULL) {
|
||||
if (ictx->event != NULL) {
|
||||
log_debug("%s: %s", __func__, reply);
|
||||
bufferevent_write(bev, reply, strlen(reply));
|
||||
bufferevent_write(ictx->event, reply, strlen(reply));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3089,8 +3087,9 @@ input_osc_133(struct input_ctx *ictx, const char *p)
|
||||
|
||||
/* Handle OSC 52 reply. */
|
||||
static void
|
||||
input_osc_52_reply(struct input_ctx *ictx)
|
||||
input_osc_52_reply(struct input_ctx *ictx, char clip)
|
||||
{
|
||||
struct bufferevent *ev = ictx->event;
|
||||
struct paste_buffer *pb;
|
||||
int state;
|
||||
const char *buf;
|
||||
@@ -3104,9 +3103,9 @@ input_osc_52_reply(struct input_ctx *ictx)
|
||||
return;
|
||||
buf = paste_buffer_data(pb, &len);
|
||||
if (ictx->input_end == INPUT_END_BEL)
|
||||
input_reply_clipboard(ictx->event, buf, len, "\007");
|
||||
input_reply_clipboard(ev, buf, len, "\007", clip);
|
||||
else
|
||||
input_reply_clipboard(ictx->event, buf, len, "\033\\");
|
||||
input_reply_clipboard(ev, buf, len, "\033\\", clip);
|
||||
return;
|
||||
}
|
||||
input_add_request(ictx, INPUT_REQUEST_CLIPBOARD, ictx->input_end);
|
||||
@@ -3119,7 +3118,7 @@ input_osc_52_reply(struct input_ctx *ictx)
|
||||
*/
|
||||
static int
|
||||
input_osc_52_parse(struct input_ctx *ictx, const char *p, u_char **out,
|
||||
int *outlen, char *flags)
|
||||
int *outlen, char *clip)
|
||||
{
|
||||
char *end;
|
||||
size_t len;
|
||||
@@ -3137,13 +3136,13 @@ input_osc_52_parse(struct input_ctx *ictx, const char *p, u_char **out,
|
||||
log_debug("%s: %s", __func__, end);
|
||||
|
||||
for (i = 0; p + i != end; i++) {
|
||||
if (strchr(allow, p[i]) != NULL && strchr(flags, p[i]) == NULL)
|
||||
flags[j++] = p[i];
|
||||
if (strchr(allow, p[i]) != NULL && strchr(clip, p[i]) == NULL)
|
||||
clip[j++] = p[i];
|
||||
}
|
||||
log_debug("%s: %.*s %s", __func__, (int)(end - p - 1), p, flags);
|
||||
log_debug("%s: %.*s %s", __func__, (int)(end - p - 1), p, clip);
|
||||
|
||||
if (strcmp(end, "?") == 0) {
|
||||
input_osc_52_reply(ictx);
|
||||
input_osc_52_reply(ictx, *clip);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -3169,9 +3168,9 @@ input_osc_52(struct input_ctx *ictx, const char *p)
|
||||
struct screen_write_ctx ctx;
|
||||
u_char *out;
|
||||
int outlen;
|
||||
char flags[sizeof "cpqs01234567"] = "";
|
||||
char clip[sizeof "cpqs01234567"] = "";
|
||||
|
||||
if (!input_osc_52_parse(ictx, p, &out, &outlen, flags))
|
||||
if (!input_osc_52_parse(ictx, p, &out, &outlen, clip))
|
||||
return;
|
||||
|
||||
if (wp == NULL) {
|
||||
@@ -3180,12 +3179,12 @@ input_osc_52(struct input_ctx *ictx, const char *p)
|
||||
free(out);
|
||||
return;
|
||||
}
|
||||
tty_set_selection(&ictx->c->tty, flags, out, outlen);
|
||||
tty_set_selection(&ictx->c->tty, clip, out, outlen);
|
||||
paste_add(NULL, out, outlen);
|
||||
} else {
|
||||
/* Normal window. */
|
||||
screen_write_start_pane(&ctx, wp, NULL);
|
||||
screen_write_setselection(&ctx, flags, out, outlen);
|
||||
screen_write_setselection(&ctx, clip, out, outlen);
|
||||
screen_write_stop(&ctx);
|
||||
notify_pane("pane-set-clipboard", wp);
|
||||
paste_add(NULL, out, outlen);
|
||||
@@ -3233,7 +3232,7 @@ input_osc_104(struct input_ctx *ictx, const char *p)
|
||||
/* Send a clipboard reply. */
|
||||
void
|
||||
input_reply_clipboard(struct bufferevent *bev, const char *buf, size_t len,
|
||||
const char *end)
|
||||
const char *end, char clip)
|
||||
{
|
||||
char *out = NULL;
|
||||
int outlen = 0;
|
||||
@@ -3249,7 +3248,10 @@ input_reply_clipboard(struct bufferevent *bev, const char *buf, size_t len,
|
||||
}
|
||||
}
|
||||
|
||||
bufferevent_write(bev, "\033]52;;", 6);
|
||||
bufferevent_write(bev, "\033]52;", 5);
|
||||
if (clip != 0)
|
||||
bufferevent_write(bev, &clip, 1);
|
||||
bufferevent_write(bev, ";", 1);
|
||||
if (outlen != 0)
|
||||
bufferevent_write(bev, out, outlen);
|
||||
bufferevent_write(bev, end, strlen(end));
|
||||
@@ -3391,6 +3393,7 @@ static void
|
||||
input_request_clipboard_reply(struct input_request *ir, void *data)
|
||||
{
|
||||
struct input_ctx *ictx = ir->ictx;
|
||||
struct bufferevent *ev = ictx->event;
|
||||
struct input_request_clipboard_data *cd = data;
|
||||
int state;
|
||||
char *copy;
|
||||
@@ -3405,9 +3408,9 @@ input_request_clipboard_reply(struct input_request *ir, void *data)
|
||||
}
|
||||
|
||||
if (ir->idx == INPUT_END_BEL)
|
||||
input_reply_clipboard(ictx->event, cd->buf, cd->len, "\007");
|
||||
input_reply_clipboard(ev, cd->buf, cd->len, "\007", cd->clip);
|
||||
else
|
||||
input_reply_clipboard(ictx->event, cd->buf, cd->len, "\033\\");
|
||||
input_reply_clipboard(ev, cd->buf, cd->len, "\033\\", cd->clip);
|
||||
}
|
||||
|
||||
/* Handle a reply to a request. */
|
||||
|
||||
Reference in New Issue
Block a user