summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-set-buffer.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2020-09-02 13:46:35 +0000
committernicm <nicm@openbsd.org>2020-09-02 13:46:35 +0000
commite4f0ed7f47a2df8b62b22365d2f395f60af93d4b (patch)
treee039522e22d8ecfbac4d7668c9566461bba8779c /usr.bin/tmux/cmd-set-buffer.c
parentDon't rely on wTotalLength for usbd_get_cdesc() malloc/free but on the (diff)
downloadwireguard-openbsd-e4f0ed7f47a2df8b62b22365d2f395f60af93d4b.tar.xz
wireguard-openbsd-e4f0ed7f47a2df8b62b22365d2f395f60af93d4b.zip
Add a -w flag to set- and load-buffer to send to clipboard using OSC 52.
GitHub issue 2363.
Diffstat (limited to 'usr.bin/tmux/cmd-set-buffer.c')
-rw-r--r--usr.bin/tmux/cmd-set-buffer.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/tmux/cmd-set-buffer.c b/usr.bin/tmux/cmd-set-buffer.c
index 24a6ffe0ee2..bf5c4857c40 100644
--- a/usr.bin/tmux/cmd-set-buffer.c
+++ b/usr.bin/tmux/cmd-set-buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-set-buffer.c,v 1.29 2020/04/13 08:26:27 nicm Exp $ */
+/* $OpenBSD: cmd-set-buffer.c,v 1.30 2020/09/02 13:46:35 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -33,10 +33,11 @@ const struct cmd_entry cmd_set_buffer_entry = {
.name = "set-buffer",
.alias = "setb",
- .args = { "ab:n:", 0, 1 },
- .usage = "[-a] " CMD_BUFFER_USAGE " [-n new-buffer-name] data",
+ .args = { "ab:t:n:w", 0, 1 },
+ .usage = "[-aw] " CMD_BUFFER_USAGE " [-n new-buffer-name] "
+ CMD_TARGET_CLIENT_USAGE " data",
- .flags = CMD_AFTERHOOK,
+ .flags = CMD_AFTERHOOK|CMD_CLIENT_TFLAG|CMD_CLIENT_CANFAIL,
.exec = cmd_set_buffer_exec
};
@@ -55,6 +56,7 @@ static enum cmd_retval
cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = cmd_get_args(self);
+ struct client *tc = cmdq_get_target_client(item);
struct paste_buffer *pb;
char *bufdata, *cause;
const char *bufname, *olddata;
@@ -118,6 +120,8 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
free(cause);
return (CMD_RETURN_ERROR);
}
+ if (args_has(args, 'w') && tc != NULL)
+ tty_set_selection(&tc->tty, bufdata, bufsize);
return (CMD_RETURN_NORMAL);
}