=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-paste-buffer.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- src/usr.bin/tmux/cmd-paste-buffer.c 2015/08/29 09:25:00 1.28 +++ src/usr.bin/tmux/cmd-paste-buffer.c 2015/08/29 09:36:46 1.29 @@ -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 @@ -48,7 +48,9 @@ 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 @@ } } - 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 @@ 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();