From 65755dfdf50fb4fa4e6f2d3266e6b50684b61cb8 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 18 May 2011 20:24:30 +0000 Subject: Support setting the xterm clipboard when copying from copy mode using the xterm escape sequence for the purpose (if xterm is configured to allow it). Written by and much discussed Ailin Nemui, guidance on xterm/termcap/terminfo from Thomas Dickey. --- usr.bin/tmux/tty.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'usr.bin/tmux/tty.c') diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index d1fe3acce08..41b8c7f7051 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.105 2011/05/08 19:53:08 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.106 2011/05/18 20:24:29 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -19,8 +19,11 @@ #include #include +#include + #include #include +#include #include #include #include @@ -311,6 +314,13 @@ tty_putcode2(struct tty *tty, enum tty_code_code code, int a, int b) tty_puts(tty, tty_term_string2(tty->term, code, a, b)); } +void +tty_putcode_ptr2(struct tty *tty, enum tty_code_code code, const void *a, const void *b) +{ + if (a != NULL && b != NULL) + tty_puts(tty, tty_term_ptr2(tty->term, code, a, b)); +} + void tty_puts(struct tty *tty, const char *s) { @@ -938,6 +948,24 @@ tty_cmd_utf8character(struct tty *tty, const struct tty_ctx *ctx) tty_draw_line(tty, wp->screen, ctx->ocy, wp->xoff, wp->yoff); } +void +tty_cmd_setselection(struct tty *tty, const struct tty_ctx *ctx) +{ + char *buf; + size_t off; + + if (!tty_term_has(tty->term, TTYC_MS)) + return; + + off = 4 * ((ctx->num + 2) / 3) + 1; /* storage for base64 */ + buf = xmalloc(off); + + b64_ntop(ctx->ptr, ctx->num, buf, off); + tty_putcode_ptr2(tty, TTYC_MS, "", buf); + + xfree(buf); +} + void tty_cmd_rawstring(struct tty *tty, const struct tty_ctx *ctx) { -- cgit v1.2.3