diff options
author | Maximilian Gass <mxey@arcor.de> | 2007-09-28 21:41:52 +0000 |
---|---|---|
committer | Maximilian Gass <mxey@arcor.de> | 2007-09-28 21:41:52 +0000 |
commit | d2e035f892ac8b21889e0124157a9be4f94462d3 (patch) | |
tree | 9a712e5870d0fb8959ba3ef27ab58567c4a2e192 /server-msg.c | |
parent | 32a80a73a1c498c554371ca0adecacdd72df4b8a (diff) |
Added window renaming support (tmux rename)
Diffstat (limited to 'server-msg.c')
-rw-r--r-- | server-msg.c | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/server-msg.c b/server-msg.c index 8a680018..9ec5ecbb 100644 --- a/server-msg.c +++ b/server-msg.c @@ -1,4 +1,4 @@ -/* $Id: server-msg.c,v 1.6 2007-09-28 21:08:30 nicm Exp $ */ +/* $Id: server-msg.c,v 1.7 2007-09-28 21:41:52 mxey Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -385,12 +385,38 @@ server_msg_fn_windows(struct hdr *hdr, struct client *c) int server_msg_fn_rename(struct hdr *hdr, struct client *c) { - if (c->session == NULL) - return (0); - if (hdr->size != 0) + struct rename_data data; + char *cause; + struct window *w; + struct session *s; + + + if (hdr->size != sizeof data) fatalx("bad MSG_RENAME size"); - fatalx("not implemented"); + buffer_read(c->in, &data, hdr->size); + + data.newname[sizeof data.newname] = '\0'; + + if ((s = server_find_sessid(&data.sid, &cause)) == NULL) { + /* XXX: Send message to client */ + return (0); + } + + if (data.idx == -1) + w = s->window; + else + w = window_at(&s->windows, data.idx); + + if (w == NULL) { + /* XXX: Send message to client */ + return (0); + } + + strlcpy(w->name, data.newname, sizeof w->name); + + return (0); + } /* Last window message from client */ |