version 1.11, 2011/07/04 14:04:40 |
version 1.12, 2011/08/26 10:53:16 |
|
|
|
|
int cmd_list_panes_exec(struct cmd *, struct cmd_ctx *); |
int cmd_list_panes_exec(struct cmd *, struct cmd_ctx *); |
|
|
void cmd_list_panes_server(struct cmd_ctx *); |
void cmd_list_panes_server(struct cmd *, struct cmd_ctx *); |
void cmd_list_panes_session(struct session *, struct cmd_ctx *, int); |
void cmd_list_panes_session( |
void cmd_list_panes_window( |
struct cmd *, struct session *, struct cmd_ctx *, int); |
|
void cmd_list_panes_window(struct cmd *, |
struct session *, struct winlink *, struct cmd_ctx *, int); |
struct session *, struct winlink *, struct cmd_ctx *, int); |
|
|
const struct cmd_entry cmd_list_panes_entry = { |
const struct cmd_entry cmd_list_panes_entry = { |
"list-panes", "lsp", |
"list-panes", "lsp", |
"ast:", 0, 0, |
"asF:t:", 0, 0, |
"[-as] [-t target]", |
"[-as] [-F format] [-t target]", |
0, |
0, |
NULL, |
NULL, |
NULL, |
NULL, |
|
|
struct winlink *wl; |
struct winlink *wl; |
|
|
if (args_has(args, 'a')) |
if (args_has(args, 'a')) |
cmd_list_panes_server(ctx); |
cmd_list_panes_server(self, ctx); |
else if (args_has(args, 's')) { |
else if (args_has(args, 's')) { |
s = cmd_find_session(ctx, args_get(args, 't'), 0); |
s = cmd_find_session(ctx, args_get(args, 't'), 0); |
if (s == NULL) |
if (s == NULL) |
return (-1); |
return (-1); |
cmd_list_panes_session(s, ctx, 1); |
cmd_list_panes_session(self, s, ctx, 1); |
} else { |
} else { |
wl = cmd_find_window(ctx, args_get(args, 't'), &s); |
wl = cmd_find_window(ctx, args_get(args, 't'), &s); |
if (wl == NULL) |
if (wl == NULL) |
return (-1); |
return (-1); |
cmd_list_panes_window(s, wl, ctx, 0); |
cmd_list_panes_window(self, s, wl, ctx, 0); |
} |
} |
|
|
return (0); |
return (0); |
} |
} |
|
|
void |
void |
cmd_list_panes_server(struct cmd_ctx *ctx) |
cmd_list_panes_server(struct cmd *self, struct cmd_ctx *ctx) |
{ |
{ |
struct session *s; |
struct session *s; |
|
|
RB_FOREACH(s, sessions, &sessions) |
RB_FOREACH(s, sessions, &sessions) |
cmd_list_panes_session(s, ctx, 2); |
cmd_list_panes_session(self, s, ctx, 2); |
} |
} |
|
|
void |
void |
cmd_list_panes_session(struct session *s, struct cmd_ctx *ctx, int type) |
cmd_list_panes_session( |
|
struct cmd *self, struct session *s, struct cmd_ctx *ctx, int type) |
{ |
{ |
struct winlink *wl; |
struct winlink *wl; |
|
|
RB_FOREACH(wl, winlinks, &s->windows) |
RB_FOREACH(wl, winlinks, &s->windows) |
cmd_list_panes_window(s, wl, ctx, type); |
cmd_list_panes_window(self, s, wl, ctx, type); |
} |
} |
|
|
void |
void |
cmd_list_panes_window( |
cmd_list_panes_window(struct cmd *self, |
struct session *s, struct winlink *wl, struct cmd_ctx *ctx, int type) |
struct session *s, struct winlink *wl, struct cmd_ctx *ctx, int type) |
{ |
{ |
|
struct args *args = self->args; |
struct window_pane *wp; |
struct window_pane *wp; |
struct grid *gd; |
u_int n; |
struct grid_line *gl; |
struct format_tree *ft; |
u_int i, n; |
const char *template; |
unsigned long long size; |
char *line; |
|
|
n = 0; |
template = args_get(args, 'F'); |
TAILQ_FOREACH(wp, &wl->window->panes, entry) { |
if (template == NULL) { |
gd = wp->base.grid; |
|
|
|
size = 0; |
|
for (i = 0; i < gd->hsize; i++) { |
|
gl = &gd->linedata[i]; |
|
size += gl->cellsize * sizeof *gl->celldata; |
|
size += gl->utf8size * sizeof *gl->utf8data; |
|
} |
|
size += gd->hsize * sizeof *gd->linedata; |
|
|
|
switch (type) { |
switch (type) { |
case 0: |
case 0: |
ctx->print(ctx, |
template = "#{line}: " |
"%u: [%ux%u] [history %u/%u, %llu bytes] %%%u%s%s", |
"[#{pane_width}x#{pane_height}] [history " |
n, wp->sx, wp->sy, gd->hsize, gd->hlimit, size, |
"#{history_size}/#{history_limit}, " |
wp->id, wp == wp->window->active ? " (active)" : "", |
"#{history_bytes} bytes] #{pane_id}" |
wp->fd == -1 ? " (dead)" : ""); |
"#{?pane_active, (active),}#{?pane_dead, (dead),}"; |
break; |
break; |
case 1: |
case 1: |
ctx->print(ctx, |
template = "#{window_index}.#{line}: " |
"%d.%u: [%ux%u] [history %u/%u, %llu bytes] " |
"[#{pane_width}x#{pane_height}] [history " |
"%%%u%s%s", wl->idx, |
"#{history_size}/#{history_limit}, " |
n, wp->sx, wp->sy, gd->hsize, gd->hlimit, size, |
"#{history_bytes} bytes] #{pane_id}" |
wp->id, wp == wp->window->active ? " (active)" : "", |
"#{?pane_active, (active),}#{?pane_dead, (dead),}"; |
wp->fd == -1 ? " (dead)" : ""); |
|
break; |
break; |
case 2: |
case 2: |
ctx->print(ctx, |
template = "#{session_name}:#{window_index}.#{line}: " |
"%s:%d.%u: [%ux%u] [history %u/%u, %llu bytes] " |
"[#{pane_width}x#{pane_height}] [history " |
"%%%u%s%s", s->name, wl->idx, |
"#{history_size}/#{history_limit}, " |
n, wp->sx, wp->sy, gd->hsize, gd->hlimit, size, |
"#{history_bytes} bytes] #{pane_id}" |
wp->id, wp == wp->window->active ? " (active)" : "", |
"#{?pane_active, (active),}#{?pane_dead, (dead),}"; |
wp->fd == -1 ? " (dead)" : ""); |
|
break; |
break; |
} |
} |
|
} |
|
|
|
n = 0; |
|
TAILQ_FOREACH(wp, &wl->window->panes, entry) { |
|
ft = format_create(); |
|
format_add(ft, "line", "%u", n); |
|
format_session(ft, s); |
|
format_winlink(ft, s, wl); |
|
format_window_pane(ft, wp); |
|
|
|
line = format_expand(ft, template); |
|
ctx->print(ctx, "%s", line); |
|
xfree(line); |
|
|
|
format_free(ft); |
n++; |
n++; |
} |
} |
} |
} |