version 1.43, 2017/05/01 12:20:55 |
version 1.44, 2020/04/12 08:36:18 |
|
|
.name = "list-windows", |
.name = "list-windows", |
.alias = "lsw", |
.alias = "lsw", |
|
|
.args = { "F:at:", 0, 0 }, |
.args = { "F:f:at:", 0, 0 }, |
.usage = "[-a] [-F format] " CMD_TARGET_SESSION_USAGE, |
.usage = "[-a] [-F format] [-f filter] " CMD_TARGET_SESSION_USAGE, |
|
|
.target = { 't', CMD_FIND_SESSION, 0 }, |
.target = { 't', CMD_FIND_SESSION, 0 }, |
|
|
|
|
struct winlink *wl; |
struct winlink *wl; |
u_int n; |
u_int n; |
struct format_tree *ft; |
struct format_tree *ft; |
const char *template; |
const char *template, *filter; |
char *line; |
char *line, *expanded; |
|
int flag; |
|
|
template = args_get(args, 'F'); |
template = args_get(args, 'F'); |
if (template == NULL) { |
if (template == NULL) { |
|
|
break; |
break; |
} |
} |
} |
} |
|
filter = args_get(args, 'f'); |
|
|
n = 0; |
n = 0; |
RB_FOREACH(wl, winlinks, &s->windows) { |
RB_FOREACH(wl, winlinks, &s->windows) { |
|
|
format_add(ft, "line", "%u", n); |
format_add(ft, "line", "%u", n); |
format_defaults(ft, NULL, s, wl, NULL); |
format_defaults(ft, NULL, s, wl, NULL); |
|
|
line = format_expand(ft, template); |
if (filter != NULL) { |
cmdq_print(item, "%s", line); |
expanded = format_expand(ft, filter); |
free(line); |
flag = format_true(expanded); |
|
free(expanded); |
|
} else |
|
flag = 1; |
|
if (flag) { |
|
line = format_expand(ft, template); |
|
cmdq_print(item, "%s", line); |
|
free(line); |
|
} |
|
|
format_free(ft); |
format_free(ft); |
n++; |
n++; |