mirror of
https://github.com/tmate-io/tmate.git
synced 2025-08-09 13:54:54 +02:00
Add a choose-buffer command for easier use of the paste buffer stack.
This commit is contained in:
25
paste.c
25
paste.c
@ -20,6 +20,7 @@
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <vis.h>
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
@ -156,3 +157,27 @@ paste_replace(struct paste_stack *ps, u_int idx, char *data, size_t size)
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Convert a buffer into a visible string. */
|
||||
char *
|
||||
paste_print(struct paste_buffer *pb, size_t width)
|
||||
{
|
||||
char *buf;
|
||||
size_t len, used;
|
||||
|
||||
if (width < 3)
|
||||
width = 3;
|
||||
buf = xmalloc(width * 4 + 1);
|
||||
|
||||
len = pb->size;
|
||||
if (len > width)
|
||||
len = width;
|
||||
|
||||
used = strvisx(buf, pb->data, len, VIS_OCTAL|VIS_TAB|VIS_NL);
|
||||
if (pb->size > width || used > width) {
|
||||
buf[width - 3] = '\0';
|
||||
strlcat(buf, "...", width);
|
||||
}
|
||||
|
||||
return (buf);
|
||||
}
|
||||
|
Reference in New Issue
Block a user