Add format support to find-window. This also adds a new format placeholder "#{window_find_matches}" to put information about any content found with find-window. --- trunk/cmd-find-window.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/trunk/cmd-find-window.c b/trunk/cmd-find-window.c index 90adb1e..ff8405f 100644 --- a/trunk/cmd-find-window.c +++ b/trunk/cmd-find-window.c @@ -46,8 +46,8 @@ void cmd_find_window_free(void *); 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 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx) 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 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx) 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 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx) 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); -- 1.7.10 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users