From 308bc18947506adebc0c469528b926e31c9b52b8 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 30 Sep 2007 13:02:14 +0000 Subject: [PATCH] Window info command. --- CHANGES | 6 +++++- TODO | 1 - client-cmd.c | 4 +++- server-msg.c | 34 +++++++++++++++++++++++++++++++++- tmux.h | 3 ++- 5 files changed, 43 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index e953448d..d466268a 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +30 September 2007 + +* (nicm) Window info command for debugging, C-b I. + 29 September 2007 * (nicm) Deleting/inserting lines should follow scrolling region. Fix. @@ -76,5 +80,5 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.17 2007-09-29 21:10:26 nicm Exp $ +$Id: CHANGES,v 1.18 2007-09-30 13:02:14 nicm Exp $ diff --git a/TODO b/TODO index f65c89fa..2e261e15 100644 --- a/TODO +++ b/TODO @@ -21,7 +21,6 @@ - figure out once and for all what is going on with backspace and del - deal properly with ambiguous ops... list-sessions & list-windows - keys to add: - i : show window info (show name, title, size, tty, ...) meta-meta : pass through meta (will need this...) - commands to add: rename sessions diff --git a/client-cmd.c b/client-cmd.c index 6fa2370c..2d98d02d 100644 --- a/client-cmd.c +++ b/client-cmd.c @@ -1,4 +1,4 @@ -/* $Id: client-cmd.c,v 1.5 2007-09-28 21:41:52 mxey Exp $ */ +/* $Id: client-cmd.c,v 1.6 2007-09-30 13:02:14 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -57,6 +57,8 @@ struct cmd client_cmd_table[] = { { 'l', client_cmd_fn_msg, MSG_LAST }, { 'W', client_cmd_fn_msg, MSG_WINDOWLIST }, { 'w', client_cmd_fn_msg, MSG_WINDOWLIST }, + { 'I', client_cmd_fn_msg, MSG_WINDOWINFO }, + { 'i', client_cmd_fn_msg, MSG_WINDOWINFO }, }; #define NCLIENTCMD (sizeof client_cmd_table / sizeof client_cmd_table[0]) diff --git a/server-msg.c b/server-msg.c index 08c5918a..422896ad 100644 --- a/server-msg.c +++ b/server-msg.c @@ -1,4 +1,4 @@ -/* $Id: server-msg.c,v 1.11 2007-09-29 19:53:39 nicm Exp $ */ +/* $Id: server-msg.c,v 1.12 2007-09-30 13:02:14 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -37,6 +37,7 @@ int server_msg_fn_select(struct hdr *, struct client *); int server_msg_fn_sessions(struct hdr *, struct client *); int server_msg_fn_size(struct hdr *, struct client *); int server_msg_fn_windowlist(struct hdr *, struct client *); +int server_msg_fn_windowinfo(struct hdr *, struct client *); int server_msg_fn_windows(struct hdr *, struct client *); struct server_msg { @@ -58,6 +59,7 @@ struct server_msg server_msg_table[] = { { MSG_SESSIONS, server_msg_fn_sessions }, { MSG_SIZE, server_msg_fn_size }, { MSG_WINDOWLIST, server_msg_fn_windowlist }, + { MSG_WINDOWINFO, server_msg_fn_windowinfo }, { MSG_WINDOWS, server_msg_fn_windows }, }; #define NSERVERMSG (sizeof server_msg_table / sizeof server_msg_table[0]) @@ -472,3 +474,33 @@ server_msg_fn_windowlist(struct hdr *hdr, struct client *c) return (0); } + +/* Window info message from client */ +int +server_msg_fn_windowinfo(struct hdr *hdr, struct client *c) +{ + struct window *w; + char *buf; + size_t len; + u_int i; + + if (c->session == NULL) + return (0); + if (hdr->size != 0) + fatalx("bad MSG_WINDOWINFO size"); + + len = c->sx + 1; + buf = xmalloc(len); + + w = c->session->window; + window_index(&c->session->windows, w, &i); + xsnprintf(buf, len, "%u:%s \"%s\" (size %u,%u) (cursor %u,%u) " + "(region %u,%u)", i, w->name, w->screen.title, w->screen.sx, + w->screen.sy, w->screen.cx, w->screen.cy, w->screen.ry_upper, + w->screen.ry_lower); + + server_write_message(c, "%s", buf); + xfree(buf); + + return (0); +} diff --git a/tmux.h b/tmux.h index c1ac2cba..9fa07e71 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.27 2007-09-29 18:48:54 nicm Exp $ */ +/* $Id: tmux.h,v 1.28 2007-09-30 13:02:14 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -276,6 +276,7 @@ enum hdrtype { MSG_SELECT, MSG_SESSIONS, MSG_SIZE, + MSG_WINDOWINFO, MSG_WINDOWLIST, MSG_WINDOWS, };