aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd-load-buffer.c2
-rw-r--r--cmd-set-buffer.c2
-rw-r--r--input.c11
-rw-r--r--screen-write.c4
-rw-r--r--tmux.h6
-rw-r--r--tty.c9
-rw-r--r--window-copy.c4
7 files changed, 26 insertions, 12 deletions
diff --git a/cmd-load-buffer.c b/cmd-load-buffer.c
index 59810dea..70fd7ed9 100644
--- a/cmd-load-buffer.c
+++ b/cmd-load-buffer.c
@@ -77,7 +77,7 @@ cmd_load_buffer_done(__unused struct client *c, const char *path, int error,
} else if (tc != NULL &&
tc->session != NULL &&
(~tc->flags & CLIENT_DEAD))
- tty_set_selection(&tc->tty, copy, bsize);
+ tty_set_selection(&tc->tty, "", copy, bsize);
if (tc != NULL)
server_client_unref(tc);
}
diff --git a/cmd-set-buffer.c b/cmd-set-buffer.c
index c9ffe5ed..35e72955 100644
--- a/cmd-set-buffer.c
+++ b/cmd-set-buffer.c
@@ -131,7 +131,7 @@ cmd_set_buffer_exec(struct cmd *self, struct cmdq_item *item)
return (CMD_RETURN_ERROR);
}
if (args_has(args, 'w') && tc != NULL)
- tty_set_selection(&tc->tty, bufdata, bufsize);
+ tty_set_selection(&tc->tty, "", bufdata, bufsize);
return (CMD_RETURN_NORMAL);
}
diff --git a/input.c b/input.c
index 693b6f32..fa9dfcdf 100644
--- a/input.c
+++ b/input.c
@@ -2693,6 +2693,9 @@ input_osc_52(struct input_ctx *ictx, const char *p)
int outlen, state;
struct screen_write_ctx ctx;
struct paste_buffer *pb;
+ const char* allow = "cpqs01234567";
+ char flags[sizeof allow] = "";
+ u_int i, j = 0;
if (wp == NULL)
return;
@@ -2707,6 +2710,12 @@ input_osc_52(struct input_ctx *ictx, const char *p)
return;
log_debug("%s: %s", __func__, end);
+ for (i = 0; p + i != end; i++) {
+ if (strchr(allow, p[i]) != NULL && strchr(flags, p[i]) == NULL)
+ flags[j++] = p[i];
+ }
+ log_debug("%s: %.*s %s", __func__, (int)(end - p - 1), p, flags);
+
if (strcmp(end, "?") == 0) {
if ((pb = paste_get_top(NULL)) != NULL)
buf = paste_buffer_data(pb, &len);
@@ -2728,7 +2737,7 @@ input_osc_52(struct input_ctx *ictx, const char *p)
}
screen_write_start_pane(&ctx, wp, NULL);
- screen_write_setselection(&ctx, out, outlen);
+ screen_write_setselection(&ctx, flags, out, outlen);
screen_write_stop(&ctx);
notify_pane("pane-set-clipboard", wp);
diff --git a/screen-write.c b/screen-write.c
index 6b6a750e..213b533c 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -2085,12 +2085,14 @@ screen_write_overwrite(struct screen_write_ctx *ctx, struct grid_cell *gc,
/* Set external clipboard. */
void
-screen_write_setselection(struct screen_write_ctx *ctx, u_char *str, u_int len)
+screen_write_setselection(struct screen_write_ctx *ctx, const char *flags,
+ u_char *str, u_int len)
{
struct tty_ctx ttyctx;
screen_write_initctx(ctx, &ttyctx, 0);
ttyctx.ptr = str;
+ ttyctx.ptr2 = (void *)flags;
ttyctx.num = len;
tty_write(tty_cmd_setselection, &ttyctx);
diff --git a/tmux.h b/tmux.h
index 6a4f98dd..c8061da5 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1422,6 +1422,7 @@ struct tty_ctx {
u_int num;
void *ptr;
+ void *ptr2;
/*
* Cursor and region position before the screen was updated - this is
@@ -2279,7 +2280,7 @@ int tty_open(struct tty *, char **);
void tty_close(struct tty *);
void tty_free(struct tty *);
void tty_update_features(struct tty *);
-void tty_set_selection(struct tty *, const char *, size_t);
+void tty_set_selection(struct tty *, const char *, const char *, size_t);
void tty_write(void (*)(struct tty *, const struct tty_ctx *),
struct tty_ctx *);
void tty_cmd_alignmenttest(struct tty *, const struct tty_ctx *);
@@ -2874,7 +2875,8 @@ void screen_write_collect_end(struct screen_write_ctx *);
void screen_write_collect_add(struct screen_write_ctx *,
const struct grid_cell *);
void screen_write_cell(struct screen_write_ctx *, const struct grid_cell *);
-void screen_write_setselection(struct screen_write_ctx *, u_char *, u_int);
+void screen_write_setselection(struct screen_write_ctx *, const char *,
+ u_char *, u_int);
void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int);
void screen_write_alternateon(struct screen_write_ctx *,
struct grid_cell *, int);
diff --git a/tty.c b/tty.c
index 49cf9795..7e0a6a3e 100644
--- a/tty.c
+++ b/tty.c
@@ -671,7 +671,7 @@ static void
tty_force_cursor_colour(struct tty *tty, int c)
{
u_char r, g, b;
- char s[13] = "";
+ char s[13];
if (c != -1)
c = colour_force_rgb(c);
@@ -2082,11 +2082,12 @@ tty_cmd_cells(struct tty *tty, const struct tty_ctx *ctx)
void
tty_cmd_setselection(struct tty *tty, const struct tty_ctx *ctx)
{
- tty_set_selection(tty, ctx->ptr, ctx->num);
+ tty_set_selection(tty, ctx->ptr2, ctx->ptr, ctx->num);
}
void
-tty_set_selection(struct tty *tty, const char *buf, size_t len)
+tty_set_selection(struct tty *tty, const char *flags, const char *buf,
+ size_t len)
{
char *encoded;
size_t size;
@@ -2101,7 +2102,7 @@ tty_set_selection(struct tty *tty, const char *buf, size_t len)
b64_ntop(buf, len, encoded, size);
tty->flags |= TTY_NOBLOCK;
- tty_putcode_ptr2(tty, TTYC_MS, "", encoded);
+ tty_putcode_ptr2(tty, TTYC_MS, flags, encoded);
free(encoded);
}
diff --git a/window-copy.c b/window-copy.c
index 03070556..09304218 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -4570,7 +4570,7 @@ window_copy_copy_buffer(struct window_mode_entry *wme, const char *prefix,
if (options_get_number(global_options, "set-clipboard") != 0) {
screen_write_start_pane(&ctx, wp, NULL);
- screen_write_setselection(&ctx, buf, len);
+ screen_write_setselection(&ctx, "", buf, len);
screen_write_stop(&ctx);
notify_pane("pane-set-clipboard", wp);
}
@@ -4644,7 +4644,7 @@ window_copy_append_selection(struct window_mode_entry *wme)
if (options_get_number(global_options, "set-clipboard") != 0) {
screen_write_start_pane(&ctx, wp, NULL);
- screen_write_setselection(&ctx, buf, len);
+ screen_write_setselection(&ctx, "", buf, len);
screen_write_stop(&ctx);
notify_pane("pane-set-clipboard", wp);
}