version 1.18, 2011/01/04 00:42:46 |
version 1.19, 2012/05/22 11:35:37 |
|
|
|
|
const struct cmd_entry cmd_choose_window_entry = { |
const struct cmd_entry cmd_choose_window_entry = { |
"choose-window", NULL, |
"choose-window", NULL, |
"t:", 0, 1, |
"F:t:", 0, 1, |
CMD_TARGET_WINDOW_USAGE " [template]", |
CMD_TARGET_WINDOW_USAGE " [-F format] [template]", |
0, |
0, |
NULL, |
NULL, |
NULL, |
NULL, |
|
|
struct cmd_choose_window_data *cdata; |
struct cmd_choose_window_data *cdata; |
struct session *s; |
struct session *s; |
struct winlink *wl, *wm; |
struct winlink *wl, *wm; |
struct window *w; |
struct format_tree *ft; |
|
const char *template; |
|
char *line; |
u_int idx, cur; |
u_int idx, cur; |
char *flags, *title; |
|
const char *left, *right; |
|
|
|
if (ctx->curclient == NULL) { |
if (ctx->curclient == NULL) { |
ctx->error(ctx, "must be run interactively"); |
ctx->error(ctx, "must be run interactively"); |
|
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0) |
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0) |
return (0); |
return (0); |
|
|
|
if ((template = args_get(args, 'F')) == NULL) |
|
template = DEFAULT_WINDOW_TEMPLATE; |
|
|
cur = idx = 0; |
cur = idx = 0; |
RB_FOREACH(wm, winlinks, &s->windows) { |
RB_FOREACH(wm, winlinks, &s->windows) { |
w = wm->window; |
|
|
|
if (wm == s->curw) |
if (wm == s->curw) |
cur = idx; |
cur = idx; |
idx++; |
idx++; |
|
|
flags = window_printable_flags(s, wm); |
ft = format_create(); |
title = w->active->screen->title; |
format_add(ft, "line", "%u", idx); |
if (wm == wl) |
format_session(ft, s); |
title = w->active->base.title; |
format_winlink(ft, s, wm); |
left = " \""; |
|
right = "\""; |
|
if (*title == '\0') |
|
left = right = ""; |
|
|
|
window_choose_add(wl->window->active, |
line = format_expand(ft, template); |
wm->idx, "%3d: %s%s [%ux%u] (%u panes%s)%s%s%s", |
window_choose_add(wl->window->active, idx, "%s", line); |
wm->idx, w->name, flags, w->sx, w->sy, window_count_panes(w), |
|
w->active->fd == -1 ? ", dead" : "", |
|
left, title, right); |
|
|
|
xfree(flags); |
xfree(line); |
|
format_free(ft); |
} |
} |
|
|
cdata = xmalloc(sizeof *cdata); |
cdata = xmalloc(sizeof *cdata); |