diff --git a/CHANGES b/CHANGES index cc679b44..0e0239e4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +23 October 2007 + +* (nicm) Show size in session/window lists. +* (nicm) Pass tty up to server when client identifies and add a list-clients + command to list connected clients. + 20 October 2007 * (nicm) Add default-command option and change default to be $SHELL rather than @@ -144,5 +150,5 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.46 2007-10-20 09:57:08 nicm Exp $ +$Id: CHANGES,v 1.47 2007-10-23 09:36:19 nicm Exp $ diff --git a/Makefile b/Makefile index 5d24cfa6..a99357cc 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.29 2007-10-19 20:47:09 nicm Exp $ +# $Id: Makefile,v 1.30 2007-10-23 09:36:19 nicm Exp $ .SUFFIXES: .c .o .y .h .PHONY: clean @@ -23,7 +23,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \ cmd-unbind-key.c cmd-previous-window.c cmd-last-window.c cmd-list-keys.c \ cmd-set-option.c cmd-rename-window.c cmd-select-window.c \ cmd-list-windows.c cmd-attach-session.c cmd-send-prefix.c \ - cmd-refresh-session.c cmd-kill-window.c + cmd-refresh-session.c cmd-kill-window.c cmd-list-clients.c YACC= yacc -d diff --git a/TODO b/TODO index 1e4cf281..952fe0b7 100644 --- a/TODO +++ b/TODO @@ -34,7 +34,6 @@ - CLIENT_HOLD sucks - session with CMD_NOSESSION should be an error - each command should have a print op as well for list keys -- get rid of MAXNAMELEN limits (sessid) - List available commands on ambigous command - Implicitly add exec to the commands for new windows (switch to disable it) - nested sessions, ie session as window - moving to it moves into session @@ -44,9 +43,11 @@ kill-window to limit accidental presses - status-fg/status-bg should be to set attributes: bold, etc - show-options command +- fix resize(1) -- For 0.1 -------------------------------------------------------------------- - man page +- get rid of MAXNAMELEN limits (sessid) - commands: list clients (session, window, tty?) rename sessions @@ -54,7 +55,6 @@ link/copy windows unlink window (error if window only linked to one session) kill session (no not bind by default) - set shell -- default-command (don't forget to rm -l) - check for some reqd terminfo caps on startup -- For 0.2 -------------------------------------------------------------------- diff --git a/client.c b/client.c index 71f66aa9..081d8452 100644 --- a/client.c +++ b/client.c @@ -1,4 +1,4 @@ -/* $Id: client.c,v 1.15 2007-10-22 13:16:36 nicm Exp $ */ +/* $Id: client.c,v 1.16 2007-10-23 09:36:19 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -115,6 +115,8 @@ retry: data.sx = ws.ws_col; data.sy = ws.ws_row; + if (ttyname_r(STDIN_FILENO, data.tty, sizeof data.tty) != 0) + fatal("ttyname_r failed"); client_write_server(cctx, MSG_IDENTIFY, &data, sizeof data); } diff --git a/cmd-list-clients.c b/cmd-list-clients.c new file mode 100644 index 00000000..2ca94896 --- /dev/null +++ b/cmd-list-clients.c @@ -0,0 +1,60 @@ +/* $Id: cmd-list-clients.c,v 1.1 2007-10-23 09:36:19 nicm Exp $ */ + +/* + * Copyright (c) 2007 Nicholas Marriott + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#include +#include +#include + +#include "tmux.h" + +/* + * List all clients. + */ + +void cmd_list_clients_exec(void *, struct cmd_ctx *); + +const struct cmd_entry cmd_list_clients_entry = { + "list-clients", "lsc", "", + CMD_NOSESSION, + NULL, + cmd_list_clients_exec, + NULL, + NULL, + NULL +}; + +void +cmd_list_clients_exec(unused void *ptr, struct cmd_ctx *ctx) +{ + struct client *c; + u_int i; + + for (i = 0; i < ARRAY_LENGTH(&clients); i++) { + c = ARRAY_ITEM(&clients, i); + if (c == NULL || c->session == NULL) + continue; + + ctx->print(ctx, + "%s: %s [%ux%u]", c->tty, c->session->name, c->sx, c->sy); + } + + if (!(ctx->flags & CMD_KEY)) + server_write_client(ctx->client, MSG_EXIT, NULL, 0); +} diff --git a/cmd.c b/cmd.c index 2cfccdbf..791fdd92 100644 --- a/cmd.c +++ b/cmd.c @@ -1,4 +1,4 @@ -/* $Id: cmd.c,v 1.18 2007-10-19 11:10:35 nicm Exp $ */ +/* $Id: cmd.c,v 1.19 2007-10-23 09:36:19 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -29,6 +29,7 @@ const struct cmd_entry *cmd_table[] = { &cmd_detach_session_entry, &cmd_kill_window_entry, &cmd_last_window_entry, + &cmd_list_clients_entry, &cmd_list_keys_entry, &cmd_list_sessions_entry, &cmd_list_windows_entry, diff --git a/server-msg.c b/server-msg.c index 4b9e34b9..7b696ff5 100644 --- a/server-msg.c +++ b/server-msg.c @@ -1,4 +1,4 @@ -/* $Id: server-msg.c,v 1.27 2007-10-12 17:50:33 nicm Exp $ */ +/* $Id: server-msg.c,v 1.28 2007-10-23 09:36:19 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -160,6 +160,9 @@ server_msg_fn_identify(struct hdr *hdr, struct client *c) c->sx = data.sx; c->sy = data.sy; + data.tty[(sizeof data.tty) - 1] = '\0'; + c->tty = xstrdup(data.tty); + c->flags |= CLIENT_TERMINAL; return (0); diff --git a/server.c b/server.c index f0822f3e..f9720274 100644 --- a/server.c +++ b/server.c @@ -1,4 +1,4 @@ -/* $Id: server.c,v 1.29 2007-10-19 20:47:09 nicm Exp $ */ +/* $Id: server.c,v 1.30 2007-10-23 09:36:19 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -309,6 +309,8 @@ server_lost_client(struct client *c) ARRAY_SET(&clients, i, NULL); } + if (c->tty != NULL) + xfree(c->tty); close(c->fd); buffer_destroy(c->in); buffer_destroy(c->out); diff --git a/tmux.h b/tmux.h index f7b945b2..d28cab99 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.62 2007-10-19 20:36:08 nicm Exp $ */ +/* $Id: tmux.h,v 1.63 2007-10-23 09:36:19 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -297,6 +297,8 @@ struct msg_command_data { }; struct msg_identify_data { + char tty[TTY_NAME_MAX]; + u_int sx; u_int sy; }; @@ -426,6 +428,8 @@ ARRAY_DECL(sessions, struct session *); /* Client connection. */ struct client { + char *tty; + int fd; struct buffer *in; struct buffer *out; @@ -529,6 +533,7 @@ extern const struct cmd_entry cmd_bind_key_entry; extern const struct cmd_entry cmd_detach_session_entry; extern const struct cmd_entry cmd_kill_window_entry; extern const struct cmd_entry cmd_last_window_entry; +extern const struct cmd_entry cmd_list_clients_entry; extern const struct cmd_entry cmd_list_keys_entry; extern const struct cmd_entry cmd_list_sessions_entry; extern const struct cmd_entry cmd_list_windows_entry;