=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-find-window.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- src/usr.bin/tmux/cmd-find-window.c 2012/04/01 20:53:47 1.12 +++ src/usr.bin/tmux/cmd-find-window.c 2012/05/22 11:35:37 1.13 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-find-window.c,v 1.12 2012/04/01 20:53:47 nicm Exp $ */ +/* $OpenBSD: cmd-find-window.c,v 1.13 2012/05/22 11:35:37 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -46,8 +46,8 @@ const struct cmd_entry cmd_find_window_entry = { "find-window", "findw", - "CNt:T", 1, 4, - "[-CNT] " CMD_TARGET_WINDOW_USAGE " match-string", + "F:CNt:T", 1, 4, + "[-CNT] [-F format] " CMD_TARGET_WINDOW_USAGE " match-string", 0, NULL, NULL, @@ -85,11 +85,13 @@ struct cmd_find_window_data *cdata; struct session *s; struct winlink *wl, *wm; - struct window *w; struct window_pane *wp; + struct format_tree *ft; ARRAY_DECL(, u_int) list_idx; ARRAY_DECL(, char *) list_ctx; char *str, *sres, *sctx, *searchstr; + char *find_line; + const char *template; u_int i, line, match_flags; if (ctx->curclient == NULL) { @@ -101,6 +103,9 @@ if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) return (-1); + if ((template = args_get(args, 'F')) == NULL) + template = DEFAULT_FIND_WINDOW_TEMPLATE; + match_flags = cmd_find_window_match_flags(args); str = args->argv[0]; @@ -167,13 +172,20 @@ for (i = 0; i < ARRAY_LENGTH(&list_idx); i++) { wm = winlink_find_by_index( &s->windows, ARRAY_ITEM(&list_idx, i)); - w = wm->window; - sctx = ARRAY_ITEM(&list_ctx, i); - window_choose_add(wl->window->active, - wm->idx, "%3d: %s [%ux%u] (%u panes) %s", wm->idx, w->name, - w->sx, w->sy, window_count_panes(w), sctx); - xfree(sctx); + ft = format_create(); + format_add(ft, "line", "%u", i); + format_add(ft, "window_find_matches", "%s", + ARRAY_ITEM(&list_ctx, i)); + format_session(ft, s); + format_winlink(ft, s, wm); + + find_line = format_expand(ft, template); + + window_choose_add(wl->window->active, wm->idx, "%s", find_line); + + xfree(find_line); + format_free(ft); } cdata = xmalloc(sizeof *cdata);