version 1.199, 2022/02/15 13:11:29 |
version 1.200, 2022/03/08 12:01:19 |
|
|
{ |
{ |
struct window_pane *wp = ictx->wp; |
struct window_pane *wp = ictx->wp; |
char *end; |
char *end; |
const char *buf; |
const char *buf = NULL; |
size_t len; |
size_t len = 0; |
u_char *out; |
u_char *out; |
int outlen, state; |
int outlen, state; |
struct screen_write_ctx ctx; |
struct screen_write_ctx ctx; |
|
|
log_debug("%s: %s", __func__, end); |
log_debug("%s: %s", __func__, end); |
|
|
if (strcmp(end, "?") == 0) { |
if (strcmp(end, "?") == 0) { |
if ((pb = paste_get_top(NULL)) != NULL) { |
if ((pb = paste_get_top(NULL)) != NULL) |
buf = paste_buffer_data(pb, &len); |
buf = paste_buffer_data(pb, &len); |
outlen = 4 * ((len + 2) / 3) + 1; |
|
out = xmalloc(outlen); |
|
if ((outlen = b64_ntop(buf, len, out, outlen)) == -1) { |
|
free(out); |
|
return; |
|
} |
|
} else { |
|
outlen = 0; |
|
out = NULL; |
|
} |
|
bufferevent_write(ictx->event, "\033]52;;", 6); |
|
if (outlen != 0) |
|
bufferevent_write(ictx->event, out, outlen); |
|
if (ictx->input_end == INPUT_END_BEL) |
if (ictx->input_end == INPUT_END_BEL) |
bufferevent_write(ictx->event, "\007", 1); |
input_reply_clipboard(ictx->event, buf, len, "\007"); |
else |
else |
bufferevent_write(ictx->event, "\033\\", 2); |
input_reply_clipboard(ictx->event, buf, len, "\033\\"); |
free(out); |
|
return; |
return; |
} |
} |
|
|
|
|
if (redraw) |
if (redraw) |
screen_write_fullredraw(&ictx->ctx); |
screen_write_fullredraw(&ictx->ctx); |
free(copy); |
free(copy); |
|
} |
|
|
|
void |
|
input_reply_clipboard(struct bufferevent *bev, const char *buf, size_t len, |
|
const char *end) |
|
{ |
|
char *out = NULL; |
|
size_t outlen = 0; |
|
|
|
if (buf != NULL && len != 0) { |
|
outlen = 4 * ((len + 2) / 3) + 1; |
|
out = xmalloc(outlen); |
|
if ((outlen = b64_ntop(buf, len, out, outlen)) == -1) { |
|
free(out); |
|
return; |
|
} |
|
} |
|
|
|
bufferevent_write(bev, "\033]52;;", 6); |
|
if (outlen != 0) |
|
bufferevent_write(bev, out, outlen); |
|
bufferevent_write(bev, end, strlen(end)); |
|
free(out); |
} |
} |