Pass which clipboard is set through to the terminal, from Axel Lindskog

in GitHub issue 4858.
This commit is contained in:
nicm
2026-02-18 09:10:31 +00:00
parent fedd4440f0
commit 03f8690f9c
5 changed files with 39 additions and 27 deletions

View File

@@ -1310,7 +1310,7 @@ tty_keys_clipboard(struct tty *tty, const char *buf, size_t len, size_t *size)
{
struct client *c = tty->client;
size_t end, terminator = 0, needed;
char *copy, *out;
char *copy, *out, clip = 0;
int outlen;
struct input_request_clipboard_data cd;
@@ -1360,7 +1360,14 @@ tty_keys_clipboard(struct tty *tty, const char *buf, size_t len, size_t *size)
/* Adjust end so that it points to the start of the terminator. */
end -= terminator - 1;
/* Get the second argument. */
/*
* Save which clipboard was used from the second argument. If more than
* one is specified (should not happen), ignore the argument.
*/
if (end >= 2 && buf[0] != ';' && buf[1] == ';')
clip = buf[0];
/* Skip the second argument. */
while (end != 0 && *buf != ';') {
buf++;
end--;
@@ -1393,6 +1400,7 @@ tty_keys_clipboard(struct tty *tty, const char *buf, size_t len, size_t *size)
/* Set reply if any. */
cd.buf = out;
cd.len = outlen;
cd.clip = clip;
input_request_reply(c, INPUT_REQUEST_CLIPBOARD, &cd);
/* Create a buffer if requested. */