summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-06-03 17:43:02 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-06-03 17:43:02 +0000
commit228f3886c7baedf98136d64405ea6c9baea2b9ed (patch)
tree446ecc9588ce0db336bc6e6ffb686ad70fb7fa48 /usr.bin/tmux
parent5eae0b28e83bc518c26be1fa12022eca24b2ede0 (diff)
Make set-clipboard a three-state option so tmux itself can ignore the
sequencess.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/input.c17
-rw-r--r--usr.bin/tmux/options-table.c8
-rw-r--r--usr.bin/tmux/tmux.129
-rw-r--r--usr.bin/tmux/window-copy.c6
4 files changed, 42 insertions, 18 deletions
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c
index 54eb8607675..7eb4b20f7a8 100644
--- a/usr.bin/tmux/input.c
+++ b/usr.bin/tmux/input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input.c,v 1.122 2017/05/28 23:23:40 nicm Exp $ */
+/* $OpenBSD: input.c,v 1.123 2017/06/03 17:43:01 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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/usr.bin/tmux/options-table.c b/usr.bin/tmux/options-table.c
index 798d337678f..341fcc053ba 100644
--- a/usr.bin/tmux/options-table.c
+++ b/usr.bin/tmux/options-table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options-table.c,v 1.88 2017/05/30 21:44:59 nicm Exp $ */
+/* $OpenBSD: options-table.c,v 1.89 2017/06/03 17:43:01 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -54,6 +54,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[] = {
@@ -118,8 +121,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/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index ebfcf6b79cd..c2cdd3f0e58 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.555 2017/05/30 21:44:59 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.556 2017/06/03 17:43:01 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 30 2017 $
+.Dd $Mdocdate: June 3 2017 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -2398,17 +2398,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/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index 4a2aeed8daf..25288d80ce3 100644
--- a/usr.bin/tmux/window-copy.c
+++ b/usr.bin/tmux/window-copy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-copy.c,v 1.177 2017/05/30 21:44:59 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.178 2017/06/03 17:43:01 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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);