Window list with C-b W.

This commit is contained in:
Nicholas Marriott 2007-09-22 11:50:33 +00:00
parent 5ea2ac36e4
commit 3fef2d998f
5 changed files with 57 additions and 11 deletions

View File

@ -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 $

8
NOTES
View File

@ -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

View File

@ -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. */

View File

@ -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)

5
tmux.h
View File

@ -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. */