version 1.8, 2009/12/03 22:50:10 |
version 1.9, 2010/06/21 21:44:09 |
|
|
#include <sys/types.h> |
#include <sys/types.h> |
|
|
#include <string.h> |
#include <string.h> |
#include <vis.h> |
|
|
|
#include "tmux.h" |
#include "tmux.h" |
|
|
|
|
struct session *s; |
struct session *s; |
struct paste_buffer *pb; |
struct paste_buffer *pb; |
u_int idx; |
u_int idx; |
char tmp[51 * 4 + 1]; |
char *tmp; |
size_t size, len; |
|
|
|
if ((s = cmd_find_session(ctx, data->target)) == NULL) |
if ((s = cmd_find_session(ctx, data->target)) == NULL) |
return (-1); |
return (-1); |
|
|
idx = 0; |
idx = 0; |
while ((pb = paste_walk_stack(&s->buffers, &idx)) != NULL) { |
while ((pb = paste_walk_stack(&s->buffers, &idx)) != NULL) { |
size = pb->size; |
tmp = paste_print(pb, 50); |
|
ctx->print(ctx, |
/* Translate the first 50 characters. */ |
"%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp); |
len = size; |
xfree(tmp); |
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); |
|
} |
} |
|
|
return (0); |
return (0); |