aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES6
-rw-r--r--NOTES8
-rw-r--r--command.c6
-rw-r--r--server.c43
-rw-r--r--tmux.h5
5 files changed, 57 insertions, 11 deletions
diff --git a/CHANGES b/CHANGES
index 90445950..d24ab1d0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+22 September 2007
+
+* Window list command (C-b W). Started by Maximilian Gass, finished by me.
+
20 September 2007
* Specify meta via environment variable (META).
@@ -27,5 +31,5 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
-$Id: CHANGES,v 1.9 2007-09-20 18:48:04 nicm Exp $
+$Id: CHANGES,v 1.10 2007-09-22 11:50:33 nicm Exp $
diff --git a/NOTES b/NOTES
index b8a70ebb..bcc1b0ee 100644
--- a/NOTES
+++ b/NOTES
@@ -7,11 +7,13 @@ Command prefix is C-b. This can be changed by building with, for example:
META=\\001 make
Commands: d detach
- c create new terminal
- n next terminal
- p previous terminal
+ c create new window
+ n next window
+ p previous window
+ l last (next to last selected) window
r refresh screen
t set window name
+ w list current windows
0-9 select window
There is one default server process per user which puts its socket in
diff --git a/command.c b/command.c
index 0b992dbe..d07bd35f 100644
--- a/command.c
+++ b/command.c
@@ -1,4 +1,4 @@
-/* $Id: command.c,v 1.6 2007-09-20 18:51:34 nicm Exp $ */
+/* $Id: command.c,v 1.7 2007-09-22 11:50:33 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -56,7 +56,9 @@ struct cmd cmd_table[] = {
{ 'T', cmd_fn_msg, MSG_RENAME },
{ 't', cmd_fn_msg, MSG_RENAME },
{ 'L', cmd_fn_msg, MSG_LAST },
- { 'l', cmd_fn_msg, MSG_LAST }
+ { 'l', cmd_fn_msg, MSG_LAST },
+ { 'W', cmd_fn_msg, MSG_WINDOWLIST },
+ { 'w', cmd_fn_msg, MSG_WINDOWLIST }
};
/* Dispatch to a command. */
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)
diff --git a/tmux.h b/tmux.h
index 191f5636..4745e5cf 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1,4 +1,4 @@
-/* $Id: tmux.h,v 1.9 2007-09-20 18:03:23 nicm Exp $ */
+/* $Id: tmux.h,v 1.10 2007-09-22 11:50:33 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -282,7 +282,8 @@ enum hdrtype {
MSG_WINDOWS,
MSG_PAUSE,
MSG_RENAME,
- MSG_LAST
+ MSG_LAST,
+ MSG_WINDOWLIST
};
/* Message header structure. */