summaryrefslogtreecommitdiffstats
path: root/cmd-list-windows.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2007-10-26 12:29:07 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2007-10-26 12:29:07 +0000
commit4ba3cf60beea7be93a1de674226f412e5fec1105 (patch)
tree9a86ea8ba56e33233e28217d36446605ddab4be8 /cmd-list-windows.c
parent9f06104c3a56ad5ea2070317b776dfa84f213ffb (diff)
Reorg window data structures. Add an intermediate data type (struct winlink) to hold index and make sessions hold a RB tree of them rather than a fixed array.
Diffstat (limited to 'cmd-list-windows.c')
-rw-r--r--cmd-list-windows.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/cmd-list-windows.c b/cmd-list-windows.c
index 6807845f..a2bce816 100644
--- a/cmd-list-windows.c
+++ b/cmd-list-windows.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-list-windows.c,v 1.3 2007-10-23 09:36:07 nicm Exp $ */
+/* $Id: cmd-list-windows.c,v 1.4 2007-10-26 12:29:07 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -44,17 +44,14 @@ cmd_list_windows_exec(unused void *ptr, struct cmd_ctx *ctx)
{
struct client *c = ctx->client;
struct session *s = ctx->session;
+ struct winlink *wl;
struct window *w;
- u_int i;
-
- for (i = 0; i < ARRAY_LENGTH(&s->windows); i++) {
- w = ARRAY_ITEM(&s->windows, i);
- if (w == NULL)
- continue;
-
- ctx->print(ctx,
- "%u: %s \"%s\" (%s) [%ux%u]", i, w->name, w->screen.title,
- ttyname(w->fd), w->screen.sx, w->screen.sy);
+
+ RB_FOREACH(wl, winlinks, &s->windows) {
+ w = wl->window;
+ ctx->print(ctx, "%u: %s \"%s\" (%s) [%ux%u]", wl->idx,
+ w->name, w->screen.title, ttyname(w->fd),
+ w->screen.sx, w->screen.sy);
}
if (!(ctx->flags & CMD_KEY))