summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/tmux/cmd-paste-buffer.c33
-rw-r--r--usr.bin/tmux/cmd-save-buffer.c6
-rw-r--r--usr.bin/tmux/paste.c31
-rw-r--r--usr.bin/tmux/tmux.h4
4 files changed, 33 insertions, 41 deletions
diff --git a/usr.bin/tmux/cmd-paste-buffer.c b/usr.bin/tmux/cmd-paste-buffer.c
index 3c6b17d8017..58afe95a162 100644
--- a/usr.bin/tmux/cmd-paste-buffer.c
+++ b/usr.bin/tmux/cmd-paste-buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-paste-buffer.c,v 1.28 2015/08/29 09:25:00 nicm Exp $ */
+/* $OpenBSD: cmd-paste-buffer.c,v 1.29 2015/08/29 09:36:46 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -48,7 +48,9 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
struct window_pane *wp;
struct session *s;
struct paste_buffer *pb;
- const char *sepstr, *bufname;
+ const char *sepstr, *bufname, *bufdata, *bufend, *line;
+ size_t seplen, bufsize;
+ int bracket = args_has(args, 'p');
if (cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp) == NULL)
return (CMD_RETURN_ERROR);
@@ -67,7 +69,7 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
}
}
- if (pb != NULL) {
+ if (pb != NULL && ~wp->flags & PANE_INPUTOFF) {
sepstr = args_get(args, 's');
if (sepstr == NULL) {
if (args_has(args, 'r'))
@@ -75,10 +77,31 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
else
sepstr = "\r";
}
- paste_send_pane(pb, wp, sepstr, args_has(args, 'p'));
+ seplen = strlen(sepstr);
+
+ if (bracket && (wp->screen->mode & MODE_BRACKETPASTE))
+ bufferevent_write(wp->event, "\033[200~", 6);
+
+ bufdata = paste_buffer_data(pb, &bufsize);
+ bufend = bufdata + bufsize;
+
+ for (;;) {
+ line = memchr(bufdata, '\n', bufend - bufdata);
+ if (line == NULL)
+ break;
+
+ bufferevent_write(wp->event, bufdata, line - bufdata);
+ bufferevent_write(wp->event, sepstr, seplen);
+
+ bufdata = line + 1;
+ }
+ if (bufdata != bufend)
+ bufferevent_write(wp->event, bufdata, bufend - bufdata);
+
+ if (bracket && (wp->screen->mode & MODE_BRACKETPASTE))
+ bufferevent_write(wp->event, "\033[201~", 6);
}
- /* Delete the buffer if -d. */
if (args_has(args, 'd')) {
if (bufname == NULL)
paste_free_top();
diff --git a/usr.bin/tmux/cmd-save-buffer.c b/usr.bin/tmux/cmd-save-buffer.c
index 06e5f31c5ea..4dc46a65285 100644
--- a/usr.bin/tmux/cmd-save-buffer.c
+++ b/usr.bin/tmux/cmd-save-buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-save-buffer.c,v 1.29 2015/08/29 09:25:00 nicm Exp $ */
+/* $OpenBSD: cmd-save-buffer.c,v 1.30 2015/08/29 09:36:46 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -57,8 +57,8 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
struct client *c = cmdq->client;
struct session *s;
struct paste_buffer *pb;
- const char *path, *bufname, *bufdata;
- char *start, *end, *msg;
+ const char *path, *bufname, *bufdata, *start, *end;
+ char *msg;
size_t size, used, msglen, bufsize;
int cwd, fd;
FILE *f;
diff --git a/usr.bin/tmux/paste.c b/usr.bin/tmux/paste.c
index 62e6b10eed6..ff16fe2a766 100644
--- a/usr.bin/tmux/paste.c
+++ b/usr.bin/tmux/paste.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: paste.c,v 1.28 2015/08/29 09:25:00 nicm Exp $ */
+/* $OpenBSD: paste.c,v 1.29 2015/08/29 09:36:46 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -319,32 +319,3 @@ paste_make_sample(struct paste_buffer *pb, int utf8flag)
strlcpy(buf + width, "...", 4);
return (buf);
}
-
-/* Paste into a window pane, filtering '\n' according to separator. */
-void
-paste_send_pane(struct paste_buffer *pb, struct window_pane *wp,
- const char *sep, int bracket)
-{
- const char *data = pb->data, *end = data + pb->size, *lf;
- size_t seplen;
-
- if (wp->flags & PANE_INPUTOFF)
- return;
-
- if (bracket && (wp->screen->mode & MODE_BRACKETPASTE))
- bufferevent_write(wp->event, "\033[200~", 6);
-
- seplen = strlen(sep);
- while ((lf = memchr(data, '\n', end - data)) != NULL) {
- if (lf != data)
- bufferevent_write(wp->event, data, lf - data);
- bufferevent_write(wp->event, sep, seplen);
- data = lf + 1;
- }
-
- if (end != data)
- bufferevent_write(wp->event, data, end - data);
-
- if (bracket && (wp->screen->mode & MODE_BRACKETPASTE))
- bufferevent_write(wp->event, "\033[201~", 6);
-}
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 83b44192730..c97af5b8ca5 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.542 2015/08/29 09:25:00 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.543 2015/08/29 09:36:46 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1452,8 +1452,6 @@ void paste_add(char *, size_t);
int paste_rename(const char *, const char *, char **);
int paste_set(char *, size_t, const char *, char **);
char *paste_make_sample(struct paste_buffer *, int);
-void paste_send_pane(struct paste_buffer *, struct window_pane *,
- const char *, int);
/* format.c */
struct format_tree;