summaryrefslogtreecommitdiffstats
path: root/cmd-find-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2012-05-22 11:35:37 +0000
committerNicholas Marriott <nicm@openbsd.org>2012-05-22 11:35:37 +0000
commitebf94bc9cba6c41074fdfa1d1084ad5fff43fc24 (patch)
treef7f941af93113b5373618b569ea211c5acd7cfa4 /cmd-find-window.c
parent682884edc5ef0b6ded98b385fce3066e820317ff (diff)
Switch all of the various choose- and list- commands over to the format
infrastructure, from Thomas Adam.
Diffstat (limited to 'cmd-find-window.c')
-rw-r--r--cmd-find-window.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/cmd-find-window.c b/cmd-find-window.c
index 3ac3c68b..2d6c942f 100644
--- a/cmd-find-window.c
+++ b/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);