mirror of
https://github.com/tmux/tmux.git
synced 2025-12-21 06:46:08 +00:00
Add a get-clipboard option which when enabled (the default is off) uses
the same mechanism as palette requests to request clipboard from the terminal and forward to the requesting pane. Remove the now-redundant forward-to-pane ability from "refresh-client -l". GitHub issue 4275.
This commit is contained in:
45
tty-keys.c
45
tty-keys.c
@@ -1301,12 +1301,11 @@ tty_keys_mouse(struct tty *tty, const char *buf, size_t len, size_t *size,
|
||||
static int
|
||||
tty_keys_clipboard(struct tty *tty, const char *buf, size_t len, size_t *size)
|
||||
{
|
||||
struct client *c = tty->client;
|
||||
struct window_pane *wp;
|
||||
size_t end, terminator = 0, needed;
|
||||
char *copy, *out;
|
||||
int outlen;
|
||||
u_int i;
|
||||
struct client *c = tty->client;
|
||||
size_t end, terminator = 0, needed;
|
||||
char *copy, *out;
|
||||
int outlen;
|
||||
struct input_request_clipboard_data cd;
|
||||
|
||||
*size = 0;
|
||||
|
||||
@@ -1364,12 +1363,6 @@ tty_keys_clipboard(struct tty *tty, const char *buf, size_t len, size_t *size)
|
||||
buf++;
|
||||
end--;
|
||||
|
||||
/* If we did not request this, ignore it. */
|
||||
if (~tty->flags & TTY_OSC52QUERY)
|
||||
return (0);
|
||||
tty->flags &= ~TTY_OSC52QUERY;
|
||||
evtimer_del(&tty->clipboard_timer);
|
||||
|
||||
/* It has to be a string so copy it. */
|
||||
copy = xmalloc(end + 1);
|
||||
memcpy(copy, buf, end);
|
||||
@@ -1384,22 +1377,22 @@ tty_keys_clipboard(struct tty *tty, const char *buf, size_t len, size_t *size)
|
||||
return (0);
|
||||
}
|
||||
free(copy);
|
||||
|
||||
/* Create a new paste buffer and forward to panes. */
|
||||
log_debug("%s: %.*s", __func__, outlen, out);
|
||||
if (c->flags & CLIENT_CLIPBOARDBUFFER) {
|
||||
paste_add(NULL, out, outlen);
|
||||
c->flags &= ~CLIENT_CLIPBOARDBUFFER;
|
||||
}
|
||||
for (i = 0; i < c->clipboard_npanes; i++) {
|
||||
wp = window_pane_find_by_id(c->clipboard_panes[i]);
|
||||
if (wp != NULL)
|
||||
input_reply_clipboard(wp->event, out, outlen, "\033\\");
|
||||
}
|
||||
free(c->clipboard_panes);
|
||||
c->clipboard_panes = NULL;
|
||||
c->clipboard_npanes = 0;
|
||||
|
||||
/* Set reply if any. */
|
||||
cd.buf = out;
|
||||
cd.len = outlen;
|
||||
input_request_reply(c, INPUT_REQUEST_CLIPBOARD, &cd);
|
||||
|
||||
/* Create a buffer if requested. */
|
||||
if (tty->flags & TTY_OSC52QUERY) {
|
||||
paste_add(NULL, out, outlen);
|
||||
out = NULL;
|
||||
evtimer_del(&tty->clipboard_timer);
|
||||
tty->flags &= ~TTY_OSC52QUERY;
|
||||
}
|
||||
|
||||
free(out);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user