aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--input.c15
-rw-r--r--options-table.c6
-rw-r--r--tmux.125
-rw-r--r--window-copy.c4
4 files changed, 37 insertions, 13 deletions
diff --git a/input.c b/input.c
index ba97baec..5ba2ec5f 100644
--- a/input.c
+++ b/input.c
@@ -2103,9 +2103,13 @@ input_osc_52(struct window_pane *wp, const char *p)
char *end;
size_t len;
u_char *out;
- int outlen;
+ int outlen, state;
struct screen_write_ctx ctx;
+ state = options_get_number(global_options, "set-clipboard");
+ if (state != 2)
+ return;
+
if ((end = strchr(p, ';')) == NULL)
return;
end++;
@@ -2122,11 +2126,10 @@ input_osc_52(struct window_pane *wp, const char *p)
return;
}
- if (options_get_number(global_options, "set-clipboard")) {
- screen_write_start(&ctx, wp, NULL);
- screen_write_setselection(&ctx, out, outlen);
- screen_write_stop(&ctx);
- }
+ screen_write_start(&ctx, wp, NULL);
+ screen_write_setselection(&ctx, out, outlen);
+ screen_write_stop(&ctx);
+
paste_add(out, outlen);
}
diff --git a/options-table.c b/options-table.c
index b9b03153..9fbe85e6 100644
--- a/options-table.c
+++ b/options-table.c
@@ -53,6 +53,9 @@ static const char *options_table_bell_action_list[] = {
static const char *options_table_pane_status_list[] = {
"off", "top", "bottom", NULL
};
+static const char *options_table_set_clipboard_list[] = {
+ "off", "external", "on", NULL
+};
/* Top-level options. */
const struct options_table_entry options_table[] = {
@@ -117,8 +120,9 @@ const struct options_table_entry options_table[] = {
},
{ .name = "set-clipboard",
- .type = OPTIONS_TABLE_FLAG,
+ .type = OPTIONS_TABLE_CHOICE,
.scope = OPTIONS_TABLE_SERVER,
+ .choices = options_table_set_clipboard_list,
.default_num = 1
},
diff --git a/tmux.1 b/tmux.1
index 69348b4b..ec3d9e7b 100644
--- a/tmux.1
+++ b/tmux.1
@@ -2402,17 +2402,34 @@ Set the number of error or information messages to save in the message log for
each client.
The default is 100.
.It Xo Ic set-clipboard
-.Op Ic on | off
+.Op Ic on | external | off
.Xc
Attempt to set the terminal clipboard content using the
\ee]52;...\e007
.Xr xterm 1
-escape sequences.
-This option is on by default if there is an
+escape sequences, if there is an
.Em \&Ms
entry in the
.Xr terminfo 5
-description for the client terminal.
+description.
+If set to
+.Ic on ,
+.Nm
+will both accept the escape sequence to create a buffer and attempt to set
+the terminal clipboard.
+If set to
+.Ic external ,
+.Nm
+will attempt to set the terminal clipboard but ignore attempts
+by applications to set
+.Nm
+buffers.
+If
+.Ic off ,
+.Nm
+will neither accept the clipboard escape sequence nor attempt to set the
+clipboard.
+.Pp
Note that this feature needs to be enabled in
.Xr xterm 1
by setting the resource:
diff --git a/window-copy.c b/window-copy.c
index def4b923..31826861 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -1629,7 +1629,7 @@ window_copy_copy_buffer(struct window_pane *wp, const char *bufname, void *buf,
{
struct screen_write_ctx ctx;
- if (options_get_number(global_options, "set-clipboard")) {
+ if (options_get_number(global_options, "set-clipboard") != 0) {
screen_write_start(&ctx, wp, NULL);
screen_write_setselection(&ctx, buf, len);
screen_write_stop(&ctx);
@@ -1686,7 +1686,7 @@ window_copy_append_selection(struct window_pane *wp, const char *bufname)
if (buf == NULL)
return;
- if (options_get_number(global_options, "set-clipboard")) {
+ if (options_get_number(global_options, "set-clipboard") != 0) {
screen_write_start(&ctx, wp, NULL);
screen_write_setselection(&ctx, buf, len);
screen_write_stop(&ctx);