=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/Attic/window-choose.c,v retrieving revision 1.19 retrieving revision 1.20 diff -c -r1.19 -r1.20 *** src/usr.bin/tmux/Attic/window-choose.c 2012/06/25 14:08:55 1.19 --- src/usr.bin/tmux/Attic/window-choose.c 2012/06/25 14:27:25 1.20 *************** *** 1,4 **** ! /* $OpenBSD: window-choose.c,v 1.19 2012/06/25 14:08:55 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: window-choose.c,v 1.20 2012/06/25 14:27:25 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 133,140 **** wcd = xmalloc(sizeof *wcd); wcd->ft = format_create(); wcd->ft_template = NULL; ! wcd->action = NULL; ! wcd->raw_format = NULL; wcd->client = ctx->curclient; wcd->session = ctx->curclient->session; wcd->idx = -1; --- 133,139 ---- wcd = xmalloc(sizeof *wcd); wcd->ft = format_create(); wcd->ft_template = NULL; ! wcd->command = NULL; wcd->client = ctx->curclient; wcd->session = ctx->curclient->session; wcd->idx = -1; *************** *** 482,502 **** { struct cmd_ctx ctx; struct cmd_list *cmdlist; ! char *template, *cause; ! template = cmd_template_replace(cdata->action, ! cdata->raw_format, 1); ! if (cmd_string_parse(template, &cmdlist, &cause) != 0) { if (cause != NULL) { *cause = toupper((u_char) *cause); status_message_set(cdata->client, "%s", cause); xfree(cause); } - xfree(template); return; } - xfree(template); ctx.msgdata = NULL; ctx.curclient = cdata->client; --- 481,502 ---- { struct cmd_ctx ctx; struct cmd_list *cmdlist; ! char *cause; ! /* The command template will have already been replaced. But if it's ! * NULL, bail here. ! */ ! if (cdata->command == NULL) ! return; ! if (cmd_string_parse(cdata->command, &cmdlist, &cause) != 0) { if (cause != NULL) { *cause = toupper((u_char) *cause); status_message_set(cdata->client, "%s", cause); xfree(cause); } return; } ctx.msgdata = NULL; ctx.curclient = cdata->client; *************** *** 509,512 **** --- 509,562 ---- cmd_list_exec(cmdlist, &ctx); cmd_list_free(cmdlist); + } + + struct window_choose_data * + window_choose_add_session(struct window_pane *wp, struct cmd_ctx *ctx, + struct session *s, const char *template, char *action, u_int idx) + { + struct window_choose_data *wcd; + + wcd = window_choose_data_create(ctx); + wcd->idx = s->idx; + wcd->command = cmd_template_replace(action, s->name, 1); + wcd->ft_template = xstrdup(template); + format_add(wcd->ft, "line", "%u", idx); + format_session(wcd->ft, s); + + wcd->client->references++; + wcd->session->references++; + + window_choose_add(wp, wcd); + + return (wcd); + } + + struct window_choose_data * + window_choose_add_window(struct window_pane *wp, struct cmd_ctx *ctx, + struct session *s, struct winlink *wl, const char *template, + char *action, u_int idx) + { + struct window_choose_data *wcd; + char *action_data; + + wcd = window_choose_data_create(ctx); + + xasprintf(&action_data, "%s:%d", s->name, wl->idx); + wcd->command = cmd_template_replace(action, action_data, 1); + xfree(action_data); + + wcd->idx = wl->idx; + wcd->ft_template = xstrdup(template); + format_add(wcd->ft, "line", "%u", idx); + format_session(wcd->ft, s); + format_winlink(wcd->ft, s, wl); + format_window_pane(wcd->ft, wl->window->active); + + wcd->client->references++; + wcd->session->references++; + + window_choose_add(wp, wcd); + + return (wcd); }