summaryrefslogtreecommitdiffstats
path: root/tty.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-05-18 20:24:29 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-05-18 20:24:29 +0000
commit96e7f33da3078facc504c6c66d42956bc44b2e54 (patch)
treeca4c6e2cabdc24c01120f551081399abfc92baf7 /tty.c
parent58908fd8c54a3c8d2878a7c6f9ca566093302f92 (diff)
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.
Diffstat (limited to 'tty.c')
-rw-r--r--tty.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tty.c b/tty.c
index b423f6d8..04503b60 100644
--- a/tty.c
+++ b/tty.c
@@ -19,8 +19,11 @@
#include <sys/types.h>
#include <sys/ioctl.h>
+#include <netinet/in.h>
+
#include <errno.h>
#include <fcntl.h>
+#include <resolv.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
@@ -312,6 +315,13 @@ tty_putcode2(struct tty *tty, enum tty_code_code code, int a, int 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)
{
if (*s == '\0')
@@ -939,6 +949,24 @@ tty_cmd_utf8character(struct tty *tty, const struct tty_ctx *ctx)
}
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)
{
u_int i;