summaryrefslogtreecommitdiffstats
path: root/cmd-list-buffers.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2010-06-21 21:44:09 +0000
committerNicholas Marriott <nicm@openbsd.org>2010-06-21 21:44:09 +0000
commitef7293379f00b85cb96dd0dff128bb503e87612b (patch)
tree10ecce1d0eddb56d6c0beb008ddc87c87d703927 /cmd-list-buffers.c
parent386849edc1d7d322d6a48d334f83298ff7cb5501 (diff)
Add a choose-buffer command for easier use of the paste buffer stack.
Diffstat (limited to 'cmd-list-buffers.c')
-rw-r--r--cmd-list-buffers.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/cmd-list-buffers.c b/cmd-list-buffers.c
index 0416dfe7..c2b0edc9 100644
--- a/cmd-list-buffers.c
+++ b/cmd-list-buffers.c
@@ -19,7 +19,6 @@
#include <sys/types.h>
#include <string.h>
-#include <vis.h>
#include "tmux.h"
@@ -47,32 +46,17 @@ cmd_list_buffers_exec(struct cmd *self, struct cmd_ctx *ctx)
struct session *s;
struct paste_buffer *pb;
u_int idx;
- char tmp[51 * 4 + 1];
- size_t size, len;
+ char *tmp;
if ((s = cmd_find_session(ctx, data->target)) == NULL)
return (-1);
idx = 0;
while ((pb = paste_walk_stack(&s->buffers, &idx)) != NULL) {
- size = pb->size;
-
- /* Translate the first 50 characters. */
- len = size;
- if (len > 50)
- len = 50;
- strvisx(tmp, pb->data, len, VIS_OCTAL|VIS_TAB|VIS_NL);
-
- /*
- * If the first 50 characters were encoded as a longer string,
- * or there is definitely more data, add "...".
- */
- if (size > 50 || strlen(tmp) > 50) {
- tmp[50 - 3] = '\0';
- strlcat(tmp, "...", sizeof tmp);
- }
-
- ctx->print(ctx, "%u: %zu bytes: \"%s\"", idx - 1, size, tmp);
+ tmp = paste_print(pb, 50);
+ ctx->print(ctx,
+ "%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp);
+ xfree(tmp);
}
return (0);