diff options
author | nicm <nicm> | 2015-08-29 09:36:46 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-08-29 09:36:46 +0000 |
commit | 373ef850e0a00dfb8180054625a91d046849261e (patch) | |
tree | 55af1cce9e653e6ce87f8cb6d1059e1322f72b0c /cmd-paste-buffer.c | |
parent | b56958500036970023c7a53264331cd10a5bbed2 (diff) | |
download | rtmux-373ef850e0a00dfb8180054625a91d046849261e.tar.gz rtmux-373ef850e0a00dfb8180054625a91d046849261e.tar.bz2 rtmux-373ef850e0a00dfb8180054625a91d046849261e.zip |
paste_send_pane can be merged into cmd-paste-buffer.c now.
Diffstat (limited to 'cmd-paste-buffer.c')
-rw-r--r-- | cmd-paste-buffer.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/cmd-paste-buffer.c b/cmd-paste-buffer.c index d4ff93d1..cd3fc7d8 100644 --- a/cmd-paste-buffer.c +++ b/cmd-paste-buffer.c @@ -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(); |