Support middle-click paste, based on a diff from Ailin Nemui.

This commit is contained in:
Nicholas Marriott
2012-11-27 20:22:12 +00:00
parent 24d7d073ff
commit 47c097cb51
4 changed files with 46 additions and 38 deletions

26
paste.c
View File

@ -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);
}