On Sun, Mar 27, 2011 at 09:53:35PM +0100, Nicholas Marriott wrote: > > > 0004-Add-list-session-panes-command.patch > > > 0005-Add-list-server-panes-command.patch > > > > > > These two add commands to list panes with different scopes. Maybe a > > > list-server-windows would be in order as well? > > Hmm. I'm not at all convinced we need any new commands. I wonder if this > stuff could be hooked into existing ones as new flags.
New patches attached (-a and -s flags for server and session listing, respectively, for list-panes as well as -a for list-windows). 0005-Add-a-and-s-flags-to-list-panes.patch 0006-Add-a-flag-to-list-windows.patch > > > 0006-Fix-list-panes-documentation-to-match-the-rest.patch > > > > > > Minor fix to the manpage for list-panes to match the rest of the > > > documentation. > > > > > I think we don't need to do this, Xc/Xo are only needed in mdoc if you > hit the limit of the number of parameters to It. Removed here. > > > 0008-Add-I-flag-to-new-window-and-split-window.patch > > > > > > Add a -I flag to new-window and split-window commands (similar to > > > -P) to print the ID of the new window. Feedback? 0001 through 0003 are the same as before and 0004 is the 0008 from last time. --Ben
From 1ca8b937415788318a45dcf4671cd83b67f3c54d Mon Sep 17 00:00:00 2001 From: Ben Boeckel <maths...@gmail.com> Date: Mon, 28 Mar 2011 17:46:29 -0400 Subject: [PATCH 5/6] Add -a and -s flags to list-panes The -a flag is used to list all panes on the server and the -s flag is used to list all panes in a session. --- cmd-list-panes.c | 58 +++++++++++++++++++++++++++++++++++++++++++++-------- tmux.1 | 20 +++++++++++++++-- 2 files changed, 66 insertions(+), 12 deletions(-) diff --git a/cmd-list-panes.c b/cmd-list-panes.c index c8aa7e9..8670168 100644 --- a/cmd-list-panes.c +++ b/cmd-list-panes.c @@ -30,28 +30,70 @@ int cmd_list_panes_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_list_panes_entry = { "list-panes", "lsp", - "t:", 0, 0, - CMD_TARGET_WINDOW_USAGE, + "t:as", 0, 0, + "[-as] [-t target]", 0, NULL, NULL, cmd_list_panes_exec }; +static void cmd_list_panes_on_server(struct cmd_ctx* ctx); +static void cmd_list_panes_in_session(struct session* s, struct cmd_ctx* ctx); +static void cmd_list_panes_in_window(struct winlink* wl, struct cmd_ctx* ctx); + int cmd_list_panes_exec(struct cmd *self, struct cmd_ctx *ctx) { - struct args *args = self->args; - struct winlink *wl; + struct args *args = self->args; + struct session *s; + struct winlink *wl; + + if (args_has(args, 'a')) { + cmd_list_panes_on_server(ctx); + } else if (args_has(args, 's')) { + if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL) + return (-1); + + cmd_list_panes_in_session(s, ctx); + } else { + if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) + return (-1); + + cmd_list_panes_in_window(wl, ctx); + } + + return (0); +} + +void +cmd_list_panes_on_server(struct cmd_ctx* ctx) +{ + struct session *s; + + RB_FOREACH(s, sessions, &sessions) { + cmd_list_panes_in_session(s, ctx); + } +} + +void +cmd_list_panes_in_session(struct session* s, struct cmd_ctx* ctx) +{ + struct winlink *wl; + + RB_FOREACH(wl, winlinks, &s->windows) { + cmd_list_panes_in_window(wl, ctx); + } +} + +void cmd_list_panes_in_window(struct winlink* wl, struct cmd_ctx* ctx) +{ struct window_pane *wp; struct grid *gd; struct grid_line *gl; u_int i, n; unsigned long long size; - if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) - return (-1); - n = 0; TAILQ_FOREACH(wp, &wl->window->panes, entry) { gd = wp->base.grid; @@ -70,6 +112,4 @@ cmd_list_panes_exec(struct cmd *self, struct cmd_ctx *ctx) wp->fd == -1 ? " (dead)" : ""); n++; } - - return (0); } diff --git a/tmux.1 b/tmux.1 index 4b21282..67e877d 100644 --- a/tmux.1 +++ b/tmux.1 @@ -1099,10 +1099,24 @@ exists, it is killed, otherwise an error is generated. If .Fl d is given, the newly linked window is not selected. -.It Ic list-panes Op Fl t Ar target-window +.It Xo Ic list-panes +.Op Fl as +.Op Fl t Ar target +.Xc .D1 (alias: Ic lsp ) -List the panes in the current window or in -.Ar target-window . +If +.Fl a +is given, +.Ar target +is ignored and all all panes on the server are listed. +If +.Fl s +is given, +.Ar target +is a session (or the current session). +If neither is given, +.Ar target +is a window (or the current window). .It Ic list-windows Op Fl t Ar target-session .D1 (alias: Ic lsw ) List windows in the current session or in -- 1.7.4.1
From fc562952eba5a53e66469f89b3362b335686cf8b Mon Sep 17 00:00:00 2001 From: Ben Boeckel <maths...@gmail.com> Date: Mon, 28 Mar 2011 17:47:06 -0400 Subject: [PATCH 6/6] Add -a flag to list-windows The -a flag is used to list all windows on the server. --- cmd-list-windows.c | 38 +++++++++++++++++++++++++++++++------- tmux.1 | 10 ++++++++-- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/cmd-list-windows.c b/cmd-list-windows.c index 29feabb..fe39ed4 100644 --- a/cmd-list-windows.c +++ b/cmd-list-windows.c @@ -30,25 +30,51 @@ int cmd_list_windows_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_list_windows_entry = { "list-windows", "lsw", - "t:", 0, 0, - CMD_TARGET_SESSION_USAGE, + "t:a", 0, 0, + "[-a] " CMD_TARGET_SESSION_USAGE, 0, NULL, NULL, cmd_list_windows_exec }; +static void cmd_list_windows_on_server(struct cmd_ctx *ctx); +static void cmd_list_windows_in_session(struct session* s, struct cmd_ctx *ctx); + int cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx) { struct args *args = self->args; struct session *s; + + if (args_has(args, 'a')) { + cmd_list_windows_on_server(ctx); + } else { + if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL) + return (-1); + + cmd_list_windows_in_session(s, ctx); + } + + return (0); +} + +void +cmd_list_windows_on_server(struct cmd_ctx *ctx) +{ + struct session *s; + + RB_FOREACH(s, sessions, &sessions) { + cmd_list_windows_in_session(s, ctx); + } +} + +void +cmd_list_windows_in_session(struct session* s, struct cmd_ctx *ctx) +{ struct winlink *wl; char *layout; - if ((s = cmd_find_session(ctx, args_get(args, 't'))) == NULL) - return (-1); - RB_FOREACH(wl, winlinks, &s->windows) { layout = layout_dump(wl->window); ctx->print(ctx, "%d: %s [%ux%u] [layout %s]%s", @@ -56,6 +82,4 @@ cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx) layout, wl == s->curw ? " (active)" : ""); xfree(layout); } - - return (0); } diff --git a/tmux.1 b/tmux.1 index 67e877d..a98b89f 100644 --- a/tmux.1 +++ b/tmux.1 @@ -1117,9 +1117,15 @@ is a session (or the current session). If neither is given, .Ar target is a window (or the current window). -.It Ic list-windows Op Fl t Ar target-session +.It Xo Ic list-windows +.Op Fl a +.Op Fl t Ar target-session +.Xc .D1 (alias: Ic lsw ) -List windows in the current session or in +If +.Fl a +is given, list all windows on the server. +Otherwise, list windows in the current session or in .Ar target-session . .It Xo Ic move-window .Op Fl dk -- 1.7.4.1
pgp2MEFnvbeTa.pgp
Description: PGP signature
------------------------------------------------------------------------------ Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users