version 1.21, 2012/06/25 14:08:55 |
version 1.22, 2012/06/25 14:27:25 |
|
|
cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx) |
cmd_choose_window_exec(struct cmd *self, struct cmd_ctx *ctx) |
{ |
{ |
struct args *args = self->args; |
struct args *args = self->args; |
struct window_choose_data *cdata; |
|
struct session *s; |
struct session *s; |
struct winlink *wl, *wm; |
struct winlink *wl, *wm; |
const char *template; |
const char *template; |
|
char *action; |
u_int idx, cur; |
u_int idx, cur; |
|
|
if (ctx->curclient == NULL) { |
if (ctx->curclient == NULL) { |
|
|
if ((template = args_get(args, 'F')) == NULL) |
if ((template = args_get(args, 'F')) == NULL) |
template = DEFAULT_WINDOW_TEMPLATE " \"#{pane_title}\""; |
template = DEFAULT_WINDOW_TEMPLATE " \"#{pane_title}\""; |
|
|
|
if (args->argc != 0) |
|
action = xstrdup(args->argv[0]); |
|
else |
|
action = xstrdup("select-window -t '%%'"); |
|
|
cur = idx = 0; |
cur = idx = 0; |
RB_FOREACH(wm, winlinks, &s->windows) { |
RB_FOREACH(wm, winlinks, &s->windows) { |
if (wm == s->curw) |
if (wm == s->curw) |
cur = idx; |
cur = idx; |
idx++; |
idx++; |
|
|
cdata = window_choose_data_create(ctx); |
window_choose_add_window(wl->window->active, ctx, s, wm, |
if (args->argc != 0) |
template, action, idx); |
cdata->action = xstrdup(args->argv[0]); |
|
else |
|
cdata->action = xstrdup("select-window -t '%%'"); |
|
|
|
cdata->idx = wm->idx; |
|
cdata->client->references++; |
|
cdata->session->references++; |
|
|
|
cdata->ft_template = xstrdup(template); |
|
format_add(cdata->ft, "line", "%u", idx); |
|
format_session(cdata->ft, s); |
|
format_winlink(cdata->ft, s, wm); |
|
format_window_pane(cdata->ft, wm->window->active); |
|
|
|
window_choose_add(wl->window->active, cdata); |
|
} |
} |
|
xfree(action); |
|
|
window_choose_ready(wl->window->active, |
window_choose_ready(wl->window->active, |
cur, cmd_choose_window_callback, cmd_choose_window_free); |
cur, cmd_choose_window_callback, cmd_choose_window_free); |
|
|
|
|
if (!session_alive(s)) |
if (!session_alive(s)) |
return; |
return; |
|
|
xasprintf(&cdata->raw_format, "%s:%u", s->name, cdata->idx); |
|
window_choose_ctx(cdata); |
window_choose_ctx(cdata); |
} |
} |
|
|
|
|
cdata->client->references--; |
cdata->client->references--; |
|
|
xfree(cdata->ft_template); |
xfree(cdata->ft_template); |
xfree(cdata->action); |
xfree(cdata->command); |
format_free(cdata->ft); |
format_free(cdata->ft); |
xfree(cdata); |
xfree(cdata); |
} |
} |