version 1.4, 2011/01/04 00:42:46 |
version 1.5, 2012/05/22 11:35:37 |
|
|
|
|
const struct cmd_entry cmd_choose_buffer_entry = { |
const struct cmd_entry cmd_choose_buffer_entry = { |
"choose-buffer", NULL, |
"choose-buffer", NULL, |
"t:", 0, 1, |
"F:t:", 0, 1, |
CMD_TARGET_WINDOW_USAGE " [template]", |
CMD_TARGET_WINDOW_USAGE " [-F format] [template]", |
0, |
0, |
NULL, |
NULL, |
NULL, |
NULL, |
|
|
struct cmd_choose_buffer_data *cdata; |
struct cmd_choose_buffer_data *cdata; |
struct winlink *wl; |
struct winlink *wl; |
struct paste_buffer *pb; |
struct paste_buffer *pb; |
|
struct format_tree *ft; |
u_int idx; |
u_int idx; |
char *tmp; |
char *line; |
|
const char *template; |
|
|
if (ctx->curclient == NULL) { |
if (ctx->curclient == NULL) { |
ctx->error(ctx, "must be run interactively"); |
ctx->error(ctx, "must be run interactively"); |
return (-1); |
return (-1); |
} |
} |
|
|
|
if ((template = args_get(args, 'F')) == NULL) |
|
template = DEFAULT_BUFFER_LIST_TEMPLATE; |
|
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) |
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) |
return (-1); |
return (-1); |
|
|
|
|
|
|
idx = 0; |
idx = 0; |
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) { |
while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) { |
tmp = paste_print(pb, 50); |
ft = format_create(); |
window_choose_add(wl->window->active, idx - 1, |
format_add(ft, "line", "%u", idx - 1); |
"%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp); |
format_paste_buffer(ft, pb); |
xfree(tmp); |
|
|
line = format_expand(ft, template); |
|
window_choose_add(wl->window->active, idx - 1, "%s", line); |
|
|
|
xfree(line); |
|
format_free(ft); |
} |
} |
|
|
cdata = xmalloc(sizeof *cdata); |
cdata = xmalloc(sizeof *cdata); |