diff options
author | Thomas Adam <thomas@xteddy.org> | 2020-09-02 16:01:20 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2020-09-02 16:01:20 +0100 |
commit | fc9ecdc665656a4a609b4dc96d5bf98b361b541a (patch) | |
tree | 639ed6c87e6f2b7122083cdaadf47008b5cd4a90 /tty.c | |
parent | a0fee328bf7d2cefe047f3911e7e29955f14a75a (diff) | |
parent | 37b1600d9cf7076498760372dcc20f021e4c181a (diff) | |
download | rtmux-fc9ecdc665656a4a609b4dc96d5bf98b361b541a.tar.gz rtmux-fc9ecdc665656a4a609b4dc96d5bf98b361b541a.tar.bz2 rtmux-fc9ecdc665656a4a609b4dc96d5bf98b361b541a.zip |
Merge branch 'obsd-master'
Diffstat (limited to 'tty.c')
-rw-r--r-- | tty.c | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -1896,19 +1896,27 @@ tty_cmd_cells(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; + tty_set_selection(tty, ctx->ptr, ctx->num); +} + +void +tty_set_selection(struct tty *tty, const char *buf, size_t len) +{ + char *encoded; + size_t size; if (!tty_term_has(tty->term, TTYC_MS)) return; + if (~tty->flags & TTY_STARTED) + return; - off = 4 * ((ctx->num + 2) / 3) + 1; /* storage for base64 */ - buf = xmalloc(off); + size = 4 * ((len + 2) / 3) + 1; /* storage for base64 */ + encoded = xmalloc(size); - b64_ntop(ctx->ptr, ctx->num, buf, off); - tty_putcode_ptr2(tty, TTYC_MS, "", buf); + b64_ntop(buf, len, encoded, size); + tty_putcode_ptr2(tty, TTYC_MS, "", encoded); - free(buf); + free(encoded); } void |