From 47c097cb51da9622180963af5391d142e7d4ade3 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Tue, 27 Nov 2012 20:22:12 +0000 Subject: Support middle-click paste, based on a diff from Ailin Nemui. --- paste.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'paste.c') diff --git a/paste.c b/paste.c index 886231a2..2e89a5ef 100644 --- a/paste.c +++ b/paste.c @@ -167,3 +167,29 @@ paste_print(struct paste_buffer *pb, size_t width) 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 (bracket) + 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) + bufferevent_write(wp->event, "\033[201~", 6); +} -- cgit