version 1.19, 2012/06/25 14:08:55 |
version 1.20, 2012/06/25 14:27:25 |
|
|
wcd = xmalloc(sizeof *wcd); |
wcd = xmalloc(sizeof *wcd); |
wcd->ft = format_create(); |
wcd->ft = format_create(); |
wcd->ft_template = NULL; |
wcd->ft_template = NULL; |
wcd->action = NULL; |
wcd->command = NULL; |
wcd->raw_format = NULL; |
|
wcd->client = ctx->curclient; |
wcd->client = ctx->curclient; |
wcd->session = ctx->curclient->session; |
wcd->session = ctx->curclient->session; |
wcd->idx = -1; |
wcd->idx = -1; |
|
|
{ |
{ |
struct cmd_ctx ctx; |
struct cmd_ctx ctx; |
struct cmd_list *cmdlist; |
struct cmd_list *cmdlist; |
char *template, *cause; |
char *cause; |
|
|
template = cmd_template_replace(cdata->action, |
/* The command template will have already been replaced. But if it's |
cdata->raw_format, 1); |
* NULL, bail here. |
|
*/ |
|
if (cdata->command == NULL) |
|
return; |
|
|
if (cmd_string_parse(template, &cmdlist, &cause) != 0) { |
if (cmd_string_parse(cdata->command, &cmdlist, &cause) != 0) { |
if (cause != NULL) { |
if (cause != NULL) { |
*cause = toupper((u_char) *cause); |
*cause = toupper((u_char) *cause); |
status_message_set(cdata->client, "%s", cause); |
status_message_set(cdata->client, "%s", cause); |
xfree(cause); |
xfree(cause); |
} |
} |
xfree(template); |
|
return; |
return; |
} |
} |
xfree(template); |
|
|
|
ctx.msgdata = NULL; |
ctx.msgdata = NULL; |
ctx.curclient = cdata->client; |
ctx.curclient = cdata->client; |
|
|
|
|
cmd_list_exec(cmdlist, &ctx); |
cmd_list_exec(cmdlist, &ctx); |
cmd_list_free(cmdlist); |
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); |
} |
} |