1
0
mirror of https://github.com/tmate-io/tmate-ssh-server.git synced 2020-11-18 19:53:51 -08:00

Show full targets for lsp/lsw -a.

This commit is contained in:
Nicholas Marriott 2011-07-04 14:04:40 +00:00
parent a70379d8f9
commit 26aa0689a5
2 changed files with 51 additions and 21 deletions

View File

@ -29,8 +29,9 @@
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_ctx *);
void cmd_list_panes_session(struct session *, struct cmd_ctx *); void cmd_list_panes_session(struct session *, struct cmd_ctx *, int);
void cmd_list_panes_window(struct winlink *, struct cmd_ctx *); void cmd_list_panes_window(
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",
@ -55,12 +56,12 @@ cmd_list_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
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); cmd_list_panes_session(s, ctx, 1);
} else { } else {
wl = cmd_find_window(ctx, args_get(args, 't'), NULL); wl = cmd_find_window(ctx, args_get(args, 't'), &s);
if (wl == NULL) if (wl == NULL)
return (-1); return (-1);
cmd_list_panes_window(wl, ctx); cmd_list_panes_window(s, wl, ctx, 0);
} }
return (0); return (0);
@ -72,20 +73,21 @@ cmd_list_panes_server(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); cmd_list_panes_session(s, ctx, 2);
} }
void void
cmd_list_panes_session(struct session *s, struct cmd_ctx *ctx) cmd_list_panes_session(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(wl, ctx); cmd_list_panes_window(s, wl, ctx, type);
} }
void void
cmd_list_panes_window(struct winlink *wl, struct cmd_ctx *ctx) cmd_list_panes_window(
struct session *s, struct winlink *wl, struct cmd_ctx *ctx, int type)
{ {
struct window_pane *wp; struct window_pane *wp;
struct grid *gd; struct grid *gd;
@ -105,11 +107,31 @@ cmd_list_panes_window(struct winlink *wl, struct cmd_ctx *ctx)
} }
size += gd->hsize * sizeof *gd->linedata; size += gd->hsize * sizeof *gd->linedata;
switch (type) {
case 0:
ctx->print(ctx, ctx->print(ctx,
"%u: [%ux%u] [history %u/%u, %llu bytes] %%%u%s%s", "%u: [%ux%u] [history %u/%u, %llu bytes] %%%u%s%s",
n, wp->sx, wp->sy, gd->hsize, gd->hlimit, size, wp->id, n, wp->sx, wp->sy, gd->hsize, gd->hlimit, size,
wp == wp->window->active ? " (active)" : "", wp->id, wp == wp->window->active ? " (active)" : "",
wp->fd == -1 ? " (dead)" : ""); wp->fd == -1 ? " (dead)" : "");
break;
case 1:
ctx->print(ctx,
"%d.%u: [%ux%u] [history %u/%u, %llu bytes] "
"%%%u%s%s", wl->idx,
n, wp->sx, wp->sy, gd->hsize, gd->hlimit, size,
wp->id, wp == wp->window->active ? " (active)" : "",
wp->fd == -1 ? " (dead)" : "");
break;
case 2:
ctx->print(ctx,
"%s:%d.%u: [%ux%u] [history %u/%u, %llu bytes] "
"%%%u%s%s", s->name, wl->idx,
n, wp->sx, wp->sy, gd->hsize, gd->hlimit, size,
wp->id, wp == wp->window->active ? " (active)" : "",
wp->fd == -1 ? " (dead)" : "");
break;
}
n++; n++;
} }
} }

View File

@ -29,7 +29,7 @@
int cmd_list_windows_exec(struct cmd *, struct cmd_ctx *); int cmd_list_windows_exec(struct cmd *, struct cmd_ctx *);
void cmd_list_windows_server(struct cmd_ctx *); void cmd_list_windows_server(struct cmd_ctx *);
void cmd_list_windows_session(struct session *, struct cmd_ctx *); void cmd_list_windows_session(struct session *, struct cmd_ctx *, int);
const struct cmd_entry cmd_list_windows_entry = { const struct cmd_entry cmd_list_windows_entry = {
"list-windows", "lsw", "list-windows", "lsw",
@ -53,7 +53,7 @@ cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx)
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_windows_session(s, ctx); cmd_list_windows_session(s, ctx, 0);
} }
return (0); return (0);
@ -65,20 +65,28 @@ cmd_list_windows_server(struct cmd_ctx *ctx)
struct session *s; struct session *s;
RB_FOREACH(s, sessions, &sessions) RB_FOREACH(s, sessions, &sessions)
cmd_list_windows_session(s, ctx); cmd_list_windows_session(s, ctx, 1);
} }
void void
cmd_list_windows_session(struct session *s, struct cmd_ctx *ctx) cmd_list_windows_session(struct session *s, struct cmd_ctx *ctx, int type)
{ {
struct winlink *wl; struct winlink *wl;
char *layout; char *layout;
RB_FOREACH(wl, winlinks, &s->windows) { RB_FOREACH(wl, winlinks, &s->windows) {
layout = layout_dump(wl->window); layout = layout_dump(wl->window);
if (type) {
ctx->print(ctx, "%s:%d: %s [%ux%u] [layout %s]%s",
s->name, wl->idx, wl->window->name, wl->window->sx,
wl->window->sy, layout,
wl == s->curw ? " (active)" : "");
} else {
ctx->print(ctx, "%d: %s [%ux%u] [layout %s]%s", ctx->print(ctx, "%d: %s [%ux%u] [layout %s]%s",
wl->idx, wl->window->name, wl->window->sx, wl->window->sy, wl->idx, wl->window->name, wl->window->sx,
layout, wl == s->curw ? " (active)" : ""); wl->window->sy, layout,
wl == s->curw ? " (active)" : "");
}
xfree(layout); xfree(layout);
} }
} }