version 1.22, 2015/02/05 10:29:43 |
version 1.23, 2015/04/24 23:17:11 |
|
|
struct winlink *wl; |
struct winlink *wl; |
const char *template; |
const char *template; |
char *action; |
char *action; |
u_int i, idx, cur; |
u_int idx, cur; |
|
|
if ((c = cmd_current_client(cmdq)) == NULL) { |
if ((c = cmd_current_client(cmdq)) == NULL) { |
cmdq_error(cmdq, "no client available"); |
cmdq_error(cmdq, "no client available"); |
|
|
action = xstrdup("detach-client -t '%%'"); |
action = xstrdup("detach-client -t '%%'"); |
|
|
cur = idx = 0; |
cur = idx = 0; |
for (i = 0; i < ARRAY_LENGTH(&clients); i++) { |
TAILQ_FOREACH(c1, &clients, entry) { |
c1 = ARRAY_ITEM(&clients, i); |
if (c1->session == NULL || c1->tty.path == NULL) |
if (c1 == NULL || c1->session == NULL || c1->tty.path == NULL) |
|
continue; |
continue; |
if (c1 == cmdq->client) |
if (c1 == cmdq->client) |
cur = idx; |
cur = idx; |
idx++; |
|
|
|
cdata = window_choose_data_create(TREE_OTHER, c, c->session); |
cdata = window_choose_data_create(TREE_OTHER, c, c->session); |
cdata->idx = i; |
cdata->idx = idx; |
|
|
cdata->ft_template = xstrdup(template); |
cdata->ft_template = xstrdup(template); |
format_add(cdata->ft, "line", "%u", i); |
format_add(cdata->ft, "line", "%u", idx); |
format_defaults(cdata->ft, c1, NULL, NULL, NULL); |
format_defaults(cdata->ft, c1, NULL, NULL, NULL); |
|
|
cdata->command = cmd_template_replace(action, c1->tty.path, 1); |
cdata->command = cmd_template_replace(action, c1->tty.path, 1); |
|
|
window_choose_add(wl->window->active, cdata); |
window_choose_add(wl->window->active, cdata); |
|
|
|
idx++; |
} |
} |
free(action); |
free(action); |
|
|
|
|
cmd_choose_client_callback(struct window_choose_data *cdata) |
cmd_choose_client_callback(struct window_choose_data *cdata) |
{ |
{ |
struct client *c; |
struct client *c; |
|
u_int idx; |
|
|
if (cdata == NULL) |
if (cdata == NULL) |
return; |
return; |
if (cdata->start_client->flags & CLIENT_DEAD) |
if (cdata->start_client->flags & CLIENT_DEAD) |
return; |
return; |
|
|
if (cdata->idx > ARRAY_LENGTH(&clients) - 1) |
idx = 0; |
return; |
TAILQ_FOREACH(c, &clients, entry) { |
c = ARRAY_ITEM(&clients, cdata->idx); |
if (idx == cdata->idx) |
|
break; |
|
idx++; |
|
} |
if (c == NULL || c->session == NULL) |
if (c == NULL || c->session == NULL) |
return; |
return; |
|
|