mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 05:21:10 +00:00
Add a -w flag to set- and load-buffer to send to clipboard using OSC 52.
GitHub issue 2363.
This commit is contained in:
22
tty.c
22
tty.c
@ -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
|
||||
|
Reference in New Issue
Block a user