From f85208602ddd43ba55f29beae8d7a05cbfedefc1 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 15 Feb 2022 13:03:02 +0000 Subject: Do not create a buffer from an OSC 52 response if we have not sent a query. --- cmd-refresh-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd-refresh-client.c') diff --git a/cmd-refresh-client.c b/cmd-refresh-client.c index 821558ae..2af9cb46 100644 --- a/cmd-refresh-client.c +++ b/cmd-refresh-client.c @@ -225,7 +225,7 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item) } if (args_has(args, 'l')) { - tty_putcode_ptr2(&tc->tty, TTYC_MS, "", "?"); + tty_send_osc52_query(&tc->tty); return (CMD_RETURN_NORMAL); } -- cgit From ad9b8059836d424f70a8579d28e28e0186cdbaa6 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 8 Mar 2022 12:01:19 +0000 Subject: Add argument to refresh-client -l to forward clipboard to a pane. GitHub issue 3068. --- cmd-refresh-client.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'cmd-refresh-client.c') diff --git a/cmd-refresh-client.c b/cmd-refresh-client.c index 2af9cb46..b2665ad9 100644 --- a/cmd-refresh-client.c +++ b/cmd-refresh-client.c @@ -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]", @@ -162,6 +162,37 @@ out: free(copy); } +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) { @@ -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')); -- cgit From 3a6d82b7c8d4254fa87959d8cf19b313f5e05480 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 6 Apr 2022 16:39:46 +0100 Subject: Some style nits. --- cmd-refresh-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd-refresh-client.c') diff --git a/cmd-refresh-client.c b/cmd-refresh-client.c index b2665ad9..6b947280 100644 --- a/cmd-refresh-client.c +++ b/cmd-refresh-client.c @@ -185,7 +185,7 @@ cmd_refresh_client_clipboard(struct cmd *self, struct cmdq_item *item) } if (i != tc->clipboard_npanes) return (CMD_RETURN_NORMAL); - tc->clipboard_panes = xreallocarray (tc->clipboard_panes, + tc->clipboard_panes = xreallocarray(tc->clipboard_panes, tc->clipboard_npanes + 1, sizeof *tc->clipboard_panes); tc->clipboard_panes[tc->clipboard_npanes++] = fs.wp->id; } -- cgit