=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/Attic/cmd-choose-buffer.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- src/usr.bin/tmux/Attic/cmd-choose-buffer.c 2011/01/04 00:42:46 1.4 +++ src/usr.bin/tmux/Attic/cmd-choose-buffer.c 2012/05/22 11:35:37 1.5 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-choose-buffer.c,v 1.4 2011/01/04 00:42:46 nicm Exp $ */ +/* $OpenBSD: cmd-choose-buffer.c,v 1.5 2012/05/22 11:35:37 nicm Exp $ */ /* * Copyright (c) 2010 Nicholas Marriott @@ -33,8 +33,8 @@ const struct cmd_entry cmd_choose_buffer_entry = { "choose-buffer", NULL, - "t:", 0, 1, - CMD_TARGET_WINDOW_USAGE " [template]", + "F:t:", 0, 1, + CMD_TARGET_WINDOW_USAGE " [-F format] [template]", 0, NULL, NULL, @@ -53,14 +53,19 @@ struct cmd_choose_buffer_data *cdata; struct winlink *wl; struct paste_buffer *pb; + struct format_tree *ft; u_int idx; - char *tmp; + char *line; + const char *template; if (ctx->curclient == NULL) { ctx->error(ctx, "must be run interactively"); 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) return (-1); @@ -72,10 +77,15 @@ idx = 0; while ((pb = paste_walk_stack(&global_buffers, &idx)) != NULL) { - tmp = paste_print(pb, 50); - window_choose_add(wl->window->active, idx - 1, - "%u: %zu bytes: \"%s\"", idx - 1, pb->size, tmp); - xfree(tmp); + ft = format_create(); + format_add(ft, "line", "%u", idx - 1); + format_paste_buffer(ft, pb); + + line = format_expand(ft, template); + window_choose_add(wl->window->active, idx - 1, "%s", line); + + xfree(line); + format_free(ft); } cdata = xmalloc(sizeof *cdata);