summaryrefslogtreecommitdiffstats
path: root/server.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2007-09-22 11:50:33 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2007-09-22 11:50:33 +0000
commit3fef2d998fb0fd1f4fd9f4b96c33816acf523567 (patch)
tree8c3efe4557f9492d495ef02b139b96b00bf4874a /server.c
parent5ea2ac36e4eaf1ae3303ada380cad8b4bbcbfe8f (diff)
Window list with C-b W.
Diffstat (limited to 'server.c')
-rw-r--r--server.c43
1 files changed, 40 insertions, 3 deletions
diff --git a/server.c b/server.c
index b56ec012..253725a5 100644
--- a/server.c
+++ b/server.c
@@ -1,4 +1,4 @@
-/* $Id: server.c,v 1.10 2007-09-21 19:24:37 nicm Exp $ */
+/* $Id: server.c,v 1.11 2007-09-22 11:50:33 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -76,6 +76,7 @@ void process_sessions_msg(struct client *, struct hdr *);
void process_windows_msg(struct client *, struct hdr *);
void process_rename_msg(struct client *, struct hdr *);
void process_last_msg(struct client *, struct hdr *);
+void process_windowlist_msg(struct client *, struct hdr *);
void rename_callback(struct client *, const char *);
/* Fork and start server process. */
@@ -383,11 +384,11 @@ write_message(struct client *c, const char *fmt, ...)
input_store16(c->out, 7);
va_start(ap, fmt);
xvasprintf(&msg, fmt, ap);
- buffer_write(c->out, msg, strlen(msg));
- xfree(msg);
va_end(ap);
+ buffer_write(c->out, msg, strlen(msg));
for (i = strlen(msg); i < c->sx; i++)
input_store8(c->out, ' ');
+ xfree(msg);
size = BUFFER_USED(c->out) - size;
hdr.type = MSG_OUTPUT;
@@ -778,6 +779,9 @@ process_client(struct client *c)
case MSG_LAST:
process_last_msg(c, &hdr);
break;
+ case MSG_WINDOWLIST:
+ process_windowlist_msg(c, &hdr);
+ break;
default:
fatalx("unexpected message");
}
@@ -1086,6 +1090,39 @@ process_last_msg(struct client *c, struct hdr *hdr)
write_message(c, "No last window");
}
+/* Window list message from client */
+void
+process_windowlist_msg(struct client *c, struct hdr *hdr)
+{
+ struct window *w;
+ char *buf;
+ size_t len, off;
+ u_int i;
+
+ if (c->session == NULL)
+ return;
+ if (hdr->size != 0)
+ fatalx("bad MSG_WINDOWLIST size");
+
+ len = c->sx + 1;
+ buf = xmalloc(len);
+ off = 0;
+
+ *buf = '\0';
+ for (i = 0; i < ARRAY_LENGTH(&c->session->windows); i++) {
+ w = ARRAY_ITEM(&c->session->windows, i);
+ if (w == NULL)
+ continue;
+ off += xsnprintf(buf + off, len - off, "%u:%s%s ", i, w->name,
+ w == c->session->window ? "*" : "");
+ if (off >= len)
+ break;
+ }
+
+ write_message(c, "%s", buf);
+ xfree(buf);
+}
+
/* Callback for rename. */
void
rename_callback(struct client *c, const char *string)