summaryrefslogtreecommitdiffstats
path: root/cmd-paste-buffer.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2015-08-30 21:44:01 +0100
committerThomas Adam <thomas@xteddy.org>2015-08-30 21:44:01 +0100
commitcb89f2f2a197db5bf7e1acc8248f381c6f0410cd (patch)
tree9074f8aa373b1bcb857fee46a47d305152cacf06 /cmd-paste-buffer.c
parent486421ceff1b4d618d84ac3cb8c4dd9135b7960d (diff)
parentb87dc608d9b5b470926aaf77c5956befdfb7bc7b (diff)
Merge branch 'obsd-master'
Conflicts: Makefile format.c
Diffstat (limited to 'cmd-paste-buffer.c')
-rw-r--r--cmd-paste-buffer.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/cmd-paste-buffer.c b/cmd-paste-buffer.c
index 5d91aeff..5027a4f8 100644
--- a/cmd-paste-buffer.c
+++ b/cmd-paste-buffer.c
@@ -47,7 +47,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);
@@ -57,7 +59,7 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
bufname = args_get(args, 'b');
if (bufname == NULL)
- pb = paste_get_top();
+ pb = paste_get_top(NULL);
else {
pb = paste_get_name(bufname);
if (pb == NULL) {
@@ -66,7 +68,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'))
@@ -74,10 +76,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();