version 1.6, 2011/08/16 10:00:52 |
version 1.7, 2012/05/22 11:35:37 |
|
|
|
|
const struct cmd_entry cmd_choose_client_entry = { |
const struct cmd_entry cmd_choose_client_entry = { |
"choose-client", NULL, |
"choose-client", 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 args *args = self->args; |
struct args *args = self->args; |
struct cmd_choose_client_data *cdata; |
struct cmd_choose_client_data *cdata; |
|
struct format_tree *ft; |
struct winlink *wl; |
struct winlink *wl; |
struct client *c; |
struct client *c; |
|
char *line; |
|
const char *template; |
u_int i, idx, cur; |
u_int i, idx, cur; |
|
|
if (ctx->curclient == NULL) { |
if (ctx->curclient == NULL) { |
|
|
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_CLIENT_TEMPLATE; |
|
|
cur = idx = 0; |
cur = idx = 0; |
for (i = 0; i < ARRAY_LENGTH(&clients); i++) { |
for (i = 0; i < ARRAY_LENGTH(&clients); i++) { |
c = ARRAY_ITEM(&clients, i); |
c = ARRAY_ITEM(&clients, i); |
|
|
cur = idx; |
cur = idx; |
idx++; |
idx++; |
|
|
window_choose_add(wl->window->active, i, |
ft = format_create(); |
"%s: %s [%ux%u %s]%s%s", c->tty.path, |
format_add(ft, "line", "%u", i); |
c->session->name, c->tty.sx, c->tty.sy, |
format_session(ft, c->session); |
c->tty.termname, |
format_client(ft, c); |
c->tty.flags & TTY_UTF8 ? " (utf8)" : "", |
|
c->flags & CLIENT_READONLY ? " (ro)" : ""); |
line = format_expand(ft, template); |
|
window_choose_add(wl->window->active, i, "%s", line); |
|
xfree(line); |
|
|
|
format_free(ft); |
} |
} |
|
|
cdata = xmalloc(sizeof *cdata); |
cdata = xmalloc(sizeof *cdata); |