diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2012-11-27 20:22:12 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2012-11-27 20:22:12 +0000 |
commit | 47c097cb51da9622180963af5391d142e7d4ade3 (patch) | |
tree | 89a59136eb48394945f0ddfda370c762d240f51b /paste.c | |
parent | 24d7d073fffbf5137176ef474f13f4cfe1f032e9 (diff) |
Support middle-click paste, based on a diff from Ailin Nemui.
Diffstat (limited to 'paste.c')
-rw-r--r-- | paste.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -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); +} |