summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-refresh-client.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2022-03-08 12:01:20 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2022-03-08 12:01:20 +0000
commit9d6f739176cb81ec9ec55f2b9b2d723238a8e907 (patch)
treeff837ad37e6ff0a528c393a16759f3d469eecbb6 /usr.bin/tmux/cmd-refresh-client.c
parent82818afa790bf3421e5c9dfc381f4a9c70cdcd80 (diff)
Add argument to refresh-client -l to forward clipboard to a pane. GitHub
issue 3068.
Diffstat (limited to 'usr.bin/tmux/cmd-refresh-client.c')
-rw-r--r--usr.bin/tmux/cmd-refresh-client.c41
1 files changed, 35 insertions, 6 deletions
diff --git a/usr.bin/tmux/cmd-refresh-client.c b/usr.bin/tmux/cmd-refresh-client.c
index 696d5717e26..eb7db1e489a 100644
--- a/usr.bin/tmux/cmd-refresh-client.c
+++ b/usr.bin/tmux/cmd-refresh-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-refresh-client.c,v 1.46 2022/02/15 13:03:02 nicm Exp $ */
+/* $OpenBSD: cmd-refresh-client.c,v 1.47 2022/03/08 12:01:19 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -34,7 +34,7 @@ const struct cmd_entry cmd_refresh_client_entry = {
.name = "refresh-client",
.alias = "refresh",
- .args = { "A:B:cC:Df:F:lLRSt:U", 0, 1, NULL },
+ .args = { "A:B:cC:Df:F:l::LRSt:U", 0, 1, NULL },
.usage = "[-cDlLRSU] [-A pane:state] [-B name:what:format] "
"[-C XxY] [-f flags] " CMD_TARGET_CLIENT_USAGE " [adjustment]",
@@ -163,6 +163,37 @@ out:
}
static enum cmd_retval
+cmd_refresh_client_clipboard(struct cmd *self, struct cmdq_item *item)
+{
+ struct args *args = cmd_get_args(self);
+ struct client *tc = cmdq_get_target_client(item);
+ const char *p;
+ u_int i;
+ struct cmd_find_state fs;
+
+ p = args_get(args, 'l');
+ if (p == NULL) {
+ if (tc->flags & CLIENT_CLIPBOARDBUFFER)
+ return (CMD_RETURN_NORMAL);
+ tc->flags |= CLIENT_CLIPBOARDBUFFER;
+ } else {
+ if (cmd_find_target(&fs, item, p, CMD_FIND_PANE, 0) != 0)
+ return (CMD_RETURN_ERROR);
+ for (i = 0; i < tc->clipboard_npanes; i++) {
+ if (tc->clipboard_panes[i] == fs.wp->id)
+ break;
+ }
+ if (i != tc->clipboard_npanes)
+ return (CMD_RETURN_NORMAL);
+ tc->clipboard_panes = xreallocarray (tc->clipboard_panes,
+ tc->clipboard_npanes + 1, sizeof *tc->clipboard_panes);
+ tc->clipboard_panes[tc->clipboard_npanes++] = fs.wp->id;
+ }
+ tty_clipboard_query(&tc->tty);
+ return (CMD_RETURN_NORMAL);
+}
+
+static enum cmd_retval
cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = cmd_get_args(self);
@@ -224,10 +255,8 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_NORMAL);
}
- if (args_has(args, 'l')) {
- tty_send_osc52_query(&tc->tty);
- return (CMD_RETURN_NORMAL);
- }
+ if (args_has(args, 'l'))
+ return (cmd_refresh_client_clipboard(self, item));
if (args_has(args, 'F')) /* -F is an alias for -f */
server_client_set_flags(tc, args_get(args, 'F'));