version 1.12, 2011/01/04 00:42:46 |
version 1.13, 2012/05/22 11:35:37 |
|
|
|
|
const struct cmd_entry cmd_choose_session_entry = { |
const struct cmd_entry cmd_choose_session_entry = { |
"choose-session", NULL, |
"choose-session", 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_session_data *cdata; |
struct cmd_choose_session_data *cdata; |
struct winlink *wl; |
struct winlink *wl; |
struct session *s; |
struct session *s; |
struct session_group *sg; |
struct format_tree *ft; |
u_int idx, sgidx, cur; |
const char *template; |
char tmp[64]; |
char *line; |
|
u_int idx, cur; |
|
|
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_SESSION_TEMPLATE; |
|
|
cur = idx = 0; |
cur = idx = 0; |
RB_FOREACH(s, sessions, &sessions) { |
RB_FOREACH(s, sessions, &sessions) { |
if (s == ctx->curclient->session) |
if (s == ctx->curclient->session) |
cur = idx; |
cur = idx; |
idx++; |
idx++; |
|
|
sg = session_group_find(s); |
ft = format_create(); |
if (sg == NULL) |
format_add(ft, "line", "%u", idx); |
*tmp = '\0'; |
format_session(ft, s); |
else { |
|
sgidx = session_group_index(sg); |
|
xsnprintf(tmp, sizeof tmp, " (group %u)", sgidx); |
|
} |
|
|
|
window_choose_add(wl->window->active, s->idx, |
line = format_expand(ft, template); |
"%s: %u windows [%ux%u]%s%s", s->name, |
window_choose_add(wl->window->active, s->idx, "%s", line); |
winlink_count(&s->windows), s->sx, s->sy, |
xfree(line); |
tmp, s->flags & SESSION_UNATTACHED ? "" : " (attached)"); |
|
|
format_free(ft); |
} |
} |
|
|
cdata = xmalloc(sizeof *cdata); |
cdata = xmalloc(sizeof *cdata); |