diff options
author | 2012-11-27 20:22:12 +0000 | |
---|---|---|
committer | 2012-11-27 20:22:12 +0000 | |
commit | 7a3aab4efb9ba3115a1bf31c2bca19c7329ca554 (patch) | |
tree | 3b79c895182e05f65924bea4af8e49ff4fcc42ea /usr.bin/tmux/paste.c | |
parent | Support the 47 and 1047 SM and RM sequences (alternate screen without (diff) | |
download | wireguard-openbsd-7a3aab4efb9ba3115a1bf31c2bca19c7329ca554.tar.xz wireguard-openbsd-7a3aab4efb9ba3115a1bf31c2bca19c7329ca554.zip |
Support middle-click paste, based on a diff from Ailin Nemui.
Diffstat (limited to 'usr.bin/tmux/paste.c')
-rw-r--r-- | usr.bin/tmux/paste.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/usr.bin/tmux/paste.c b/usr.bin/tmux/paste.c index affdbe4070f..b79d41c76d0 100644 --- a/usr.bin/tmux/paste.c +++ b/usr.bin/tmux/paste.c @@ -1,4 +1,4 @@ -/* $OpenBSD: paste.c,v 1.13 2012/09/04 13:24:50 nicm Exp $ */ +/* $OpenBSD: paste.c,v 1.14 2012/11/27 20:22:12 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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); +} |