summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2007-11-16 21:12:31 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2007-11-16 21:12:31 +0000
commitb359f9b594ccd945a245e429469d3c53fb6bf859 (patch)
tree56ea1db5c03062736f52775f4c45e16f51339eb0
parent86b73cec72fc178cc612a60af2ac1d0aff3c10c5 (diff)
Add -c option to specify client, and move detach/refresh to client rather than session.
-rw-r--r--CHANGES6
-rw-r--r--GNUmakefile6
-rw-r--r--Makefile6
-rw-r--r--TODO7
-rw-r--r--cmd-attach-session.c12
-rw-r--r--cmd-bind-key.c8
-rw-r--r--cmd-detach-client.c48
-rw-r--r--cmd-detach-session.c130
-rw-r--r--cmd-has-session.c8
-rw-r--r--cmd-kill-session.c6
-rw-r--r--cmd-kill-window.c8
-rw-r--r--cmd-last-window.c8
-rw-r--r--cmd-link-window.c8
-rw-r--r--cmd-list-clients.c8
-rw-r--r--cmd-list-keys.c8
-rw-r--r--cmd-list-sessions.c8
-rw-r--r--cmd-list-windows.c8
-rw-r--r--cmd-new-session.c6
-rw-r--r--cmd-new-window.c8
-rw-r--r--cmd-next-window.c8
-rw-r--r--cmd-previous-window.c8
-rw-r--r--cmd-refresh-client.c48
-rw-r--r--cmd-refresh-session.c130
-rw-r--r--cmd-rename-session.c8
-rw-r--r--cmd-rename-window.c8
-rw-r--r--cmd-select-window.c8
-rw-r--r--cmd-send-prefix.c12
-rw-r--r--cmd-set-option.c8
-rw-r--r--cmd-swap-window.c8
-rw-r--r--cmd-unbind-key.c8
-rw-r--r--cmd-unlink-window.c10
-rw-r--r--cmd.c6
-rw-r--r--key-bindings.c20
-rw-r--r--server-msg.c58
-rw-r--r--tmux.129
-rw-r--r--tmux.c21
-rw-r--r--tmux.h11
37 files changed, 300 insertions, 416 deletions
diff --git a/CHANGES b/CHANGES
index bb44bd63..ae1b9a30 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,9 @@
16 November 2007
+* (nicm) Accept "-c client-tty" on command line to allow client manipulation
+ commands, and change detach-/refresh-session to detach-/refresh-client (this
+ loses the -a behaviour, but at some point -session versions may return, and
+ -c will allow fnmatch(3)).
* (nicm) List available commands on ambiguous command.
12 November 2007
@@ -210,4 +214,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
-$Id: CHANGES,v 1.68 2007-11-16 13:23:59 nicm Exp $
+$Id: CHANGES,v 1.69 2007-11-16 21:12:31 nicm Exp $
diff --git a/GNUmakefile b/GNUmakefile
index 346417e0..186eef67 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -1,4 +1,4 @@
-# $Id: GNUmakefile,v 1.3 2007-11-09 15:23:28 nicm Exp $
+# $Id: GNUmakefile,v 1.4 2007-11-16 21:12:31 nicm Exp $
.PHONY: clean
@@ -14,12 +14,12 @@ META?= \002
SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
xmalloc.c xmalloc-debug.c input.c input-keys.c screen.c window.c \
session.c local.c log.c client.c client-msg.c client-fn.c key-string.c \
- key-bindings.c resize.c cmd.c cmd-new-session.c cmd-detach-session.c \
+ key-bindings.c resize.c cmd.c cmd-new-session.c cmd-detach-client.c \
cmd-list-sessions.c cmd-new-window.c cmd-next-window.c cmd-bind-key.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-list-clients.c \
+ cmd-refresh-client.c cmd-kill-window.c cmd-list-clients.c \
cmd-has-session.c cmd-link-window.c cmd-unlink-window.c \
cmd-swap-window.c cmd-rename-session.c
diff --git a/Makefile b/Makefile
index 43884440..5ca34443 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.39 2007-11-12 14:21:40 nicm Exp $
+# $Id: Makefile,v 1.40 2007-11-16 21:12:31 nicm Exp $
.SUFFIXES: .c .o .y .h
.PHONY: clean
@@ -18,12 +18,12 @@ META?= \002 # C-b
SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
xmalloc.c xmalloc-debug.c input.c input-keys.c screen.c window.c \
session.c local.c log.c client.c client-msg.c client-fn.c key-string.c \
- key-bindings.c resize.c cmd.c cmd-new-session.c cmd-detach-session.c \
+ key-bindings.c resize.c cmd.c cmd-new-session.c cmd-detach-client.c \
cmd-list-sessions.c cmd-new-window.c cmd-next-window.c cmd-bind-key.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-list-clients.c \
+ cmd-refresh-client.c cmd-kill-window.c cmd-list-clients.c \
cmd-has-session.c cmd-link-window.c cmd-unlink-window.c \
cmd-swap-window.c cmd-rename-session.c cmd-kill-session.c
diff --git a/TODO b/TODO
index 91ea9013..49b0441b 100644
--- a/TODO
+++ b/TODO
@@ -53,16 +53,19 @@
- per-session toolbar state, other options
- force-default option: assume terminal supports default colours even if AX
is missing (like, eg, xterm-color in an aterm)
-- refer to windows by name etc (duplicates?)
+- refer to windows by name etc (duplicates? fnmatch?)
- commands:
kill server
command to run something without a window at all?
command to insert a key into a window (send-key)
+ extend list-clients to list clients attached to a session (-a for all?)
+ bring back detach-session to detach all clients on a session?
- function groups, bind-key ^W { select-window 0; send-key ^W } etc
- more(1) style handling for in-client output
+- allow fnmatch for -c, so that you can, eg, detach all clients
-- For 0.1 --------------------------------------------------------------------
-- fix mutt problems with redraw (mutt's) status line when reading mail
+-
-- For 0.2 --------------------------------------------------------------------
- copy and paste
diff --git a/cmd-attach-session.c b/cmd-attach-session.c
index 5f6aafc7..621c2bfd 100644
--- a/cmd-attach-session.c
+++ b/cmd-attach-session.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-attach-session.c,v 1.8 2007-11-13 09:53:46 nicm Exp $ */
+/* $Id: cmd-attach-session.c,v 1.9 2007-11-16 21:12:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -38,7 +38,7 @@ struct cmd_attach_session_data {
const struct cmd_entry cmd_attach_session_entry = {
"attach-session", "attach", "[-d]",
- CMD_CANTNEST,
+ CMD_CANTNEST|CMD_NOCLIENT,
cmd_attach_session_parse,
cmd_attach_session_exec,
cmd_attach_session_send,
@@ -87,18 +87,18 @@ cmd_attach_session_exec(void *ptr, struct cmd_ctx *ctx)
if (ctx->flags & CMD_KEY)
return;
- if (!(ctx->client->flags & CLIENT_TERMINAL)) {
+ if (!(ctx->cmdclient->flags & CLIENT_TERMINAL)) {
ctx->error(ctx, "not a terminal");
return;
}
if (data->flag_detach)
server_write_session(ctx->session, MSG_DETACH, NULL, 0);
- ctx->client->session = ctx->session;
+ ctx->cmdclient->session = ctx->session;
- server_write_client(ctx->client, MSG_READY, NULL, 0);
+ server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
recalculate_sizes();
- server_redraw_client(ctx->client);
+ server_redraw_client(ctx->cmdclient);
}
void
diff --git a/cmd-bind-key.c b/cmd-bind-key.c
index fff9a766..5f739aca 100644
--- a/cmd-bind-key.c
+++ b/cmd-bind-key.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-bind-key.c,v 1.6 2007-11-13 09:53:47 nicm Exp $ */
+/* $Id: cmd-bind-key.c,v 1.7 2007-11-16 21:12:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -39,7 +39,7 @@ struct cmd_bind_key_data {
const struct cmd_entry cmd_bind_key_entry = {
"bind-key", "bind", "key command [arguments]",
- CMD_NOSESSION,
+ CMD_NOCLIENT|CMD_NOSESSION,
cmd_bind_key_parse,
cmd_bind_key_exec,
cmd_bind_key_send,
@@ -99,8 +99,8 @@ cmd_bind_key_exec(void *ptr, unused struct cmd_ctx *ctx)
key_bindings_add(data->key, data->cmd);
data->cmd = NULL; /* avoid free */
- if (!(ctx->flags & CMD_KEY))
- server_write_client(ctx->client, MSG_EXIT, NULL, 0);
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}
void
diff --git a/cmd-detach-client.c b/cmd-detach-client.c
new file mode 100644
index 00000000..64a31b85
--- /dev/null
+++ b/cmd-detach-client.c
@@ -0,0 +1,48 @@
+/* $Id: cmd-detach-client.c,v 1.1 2007-11-16 21:12:31 nicm Exp $ */
+
+/*
+ * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
+ *
+ * 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 <sys/types.h>
+
+#include <getopt.h>
+
+#include "tmux.h"
+
+/*
+ * Detach a client.
+ */
+
+void cmd_detach_client_exec(void *, struct cmd_ctx *);
+
+const struct cmd_entry cmd_detach_client_entry = {
+ "detach-client", "detach", "",
+ CMD_NOSESSION,
+ NULL,
+ cmd_detach_client_exec,
+ NULL,
+ NULL,
+ NULL
+};
+
+void
+cmd_detach_client_exec(unused void *ptr, struct cmd_ctx *ctx)
+{
+ server_write_client(ctx->client, MSG_DETACH, NULL, 0);
+
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
+}
diff --git a/cmd-detach-session.c b/cmd-detach-session.c
deleted file mode 100644
index 6c8be72c..00000000
--- a/cmd-detach-session.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/* $Id: cmd-detach-session.c,v 1.7 2007-11-13 09:53:47 nicm Exp $ */
-
-/*
- * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
- *
- * 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 <sys/types.h>
-
-#include <getopt.h>
-
-#include "tmux.h"
-
-/*
- * Detach session. If called with -a detach all clients attached to specified
- * session, otherwise detach current session on key press only.
- */
-
-int cmd_detach_session_parse(void **, int, char **, char **);
-void cmd_detach_session_exec(void *, struct cmd_ctx *);
-void cmd_detach_session_send(void *, struct buffer *);
-void cmd_detach_session_recv(void **, struct buffer *);
-void cmd_detach_session_free(void *);
-
-struct cmd_detach_session_data {
- int flag_all;
-};
-
-const struct cmd_entry cmd_detach_session_entry = {
- "detach-session", "detach", "[-a]",
- 0,
- cmd_detach_session_parse,
- cmd_detach_session_exec,
- cmd_detach_session_send,
- cmd_detach_session_recv,
- cmd_detach_session_free
-};
-
-int
-cmd_detach_session_parse(void **ptr, int argc, char **argv, char **cause)
-{
- struct cmd_detach_session_data *data;
- int opt;
-
- *ptr = data = xmalloc(sizeof *data);
- data->flag_all = 0;
-
- while ((opt = getopt(argc, argv, "a")) != EOF) {
- switch (opt) {
- case 'a':
- data->flag_all = 1;
- break;
- default:
- goto usage;
- }
- }
- argc -= optind;
- argv += optind;
- if (argc != 0)
- goto usage;
-
- return (0);
-
-usage:
- usage(cause, "%s %s",
- cmd_detach_session_entry.name, cmd_detach_session_entry.usage);
-
- cmd_detach_session_free(data);
- return (-1);
-}
-
-void
-cmd_detach_session_exec(void *ptr, struct cmd_ctx *ctx)
-{
- struct cmd_detach_session_data *data = ptr, std = { 0 };
- struct client *c;
- u_int i;
-
- if (data == NULL)
- data = &std;
-
- if (data->flag_all) {
- for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c = ARRAY_ITEM(&clients, i);
- if (c == NULL || c->session != ctx->session)
- continue;
- server_write_client(c, MSG_DETACH, NULL, 0);
- }
- } else if (ctx->flags & CMD_KEY)
- server_write_client(ctx->client, MSG_DETACH, NULL, 0);
-
- if (!(ctx->flags & CMD_KEY))
- server_write_client(ctx->client, MSG_EXIT, NULL, 0);
-}
-
-void
-cmd_detach_session_send(void *ptr, struct buffer *b)
-{
- struct cmd_detach_session_data *data = ptr;
-
- buffer_write(b, data, sizeof *data);
-}
-
-void
-cmd_detach_session_recv(void **ptr, struct buffer *b)
-{
- struct cmd_detach_session_data *data;
-
- *ptr = data = xmalloc(sizeof *data);
- buffer_read(b, data, sizeof *data);
-}
-
-void
-cmd_detach_session_free(void *ptr)
-{
- struct cmd_detach_session_data *data = ptr;
-
- xfree(data);
-}
diff --git a/cmd-has-session.c b/cmd-has-session.c
index 692e460a..b6d3fdf5 100644
--- a/cmd-has-session.c
+++ b/cmd-has-session.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-has-session.c,v 1.2 2007-11-13 09:53:47 nicm Exp $ */
+/* $Id: cmd-has-session.c,v 1.3 2007-11-16 21:12:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -33,7 +33,7 @@ void cmd_has_session_exec(void *, struct cmd_ctx *);
const struct cmd_entry cmd_has_session_entry = {
"has-session", "has", "",
- 0,
+ CMD_NOCLIENT,
NULL,
cmd_has_session_exec,
NULL,
@@ -44,6 +44,6 @@ const struct cmd_entry cmd_has_session_entry = {
void
cmd_has_session_exec(unused void *ptr, struct cmd_ctx *ctx)
{
- if (!(ctx->flags & CMD_KEY))
- server_write_client(ctx->client, MSG_EXIT, NULL, 0);
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}
diff --git a/cmd-kill-session.c b/cmd-kill-session.c
index 40d2e902..b7853810 100644
--- a/cmd-kill-session.c
+++ b/cmd-kill-session.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-kill-session.c,v 1.2 2007-11-13 09:53:47 nicm Exp $ */
+/* $Id: cmd-kill-session.c,v 1.3 2007-11-16 21:12:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -34,7 +34,7 @@ void cmd_kill_session_exec(void *, struct cmd_ctx *);
const struct cmd_entry cmd_kill_session_entry = {
"kill-session", NULL, "",
- 0,
+ CMD_NOCLIENT,
NULL,
cmd_kill_session_exec,
NULL,
@@ -59,5 +59,5 @@ cmd_kill_session_exec(unused void *ptr, struct cmd_ctx *ctx)
session_destroy(ctx->session);
if (!(ctx->flags & CMD_KEY))
- server_write_client(ctx->client, MSG_EXIT, NULL, 0);
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}
diff --git a/cmd-kill-window.c b/cmd-kill-window.c
index 20272526..e962fc75 100644
--- a/cmd-kill-window.c
+++ b/cmd-kill-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-kill-window.c,v 1.5 2007-11-13 09:53:47 nicm Exp $ */
+/* $Id: cmd-kill-window.c,v 1.6 2007-11-16 21:12:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -39,7 +39,7 @@ struct cmd_kill_window_data {
const struct cmd_entry cmd_kill_window_entry = {
"kill-window", "killw", "[-i index]",
- 0,
+ CMD_NOCLIENT,
cmd_kill_window_parse,
cmd_kill_window_exec,
cmd_kill_window_send,
@@ -118,8 +118,8 @@ cmd_kill_window_exec(void *ptr, struct cmd_ctx *ctx)
server_redraw_client(c);
}
- if (!(ctx->flags & CMD_KEY))
- server_write_client(ctx->client, MSG_EXIT, NULL, 0);
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}
void
diff --git a/cmd-last-window.c b/cmd-last-window.c
index dd3ff6d1..7052c1f1 100644
--- a/cmd-last-window.c
+++ b/cmd-last-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-last-window.c,v 1.4 2007-11-13 09:53:47 nicm Exp $ */
+/* $Id: cmd-last-window.c,v 1.5 2007-11-16 21:12:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -31,7 +31,7 @@ void cmd_last_window_exec(void *, struct cmd_ctx *);
const struct cmd_entry cmd_last_window_entry = {
"last-window", "last", "",
- 0,
+ CMD_NOCLIENT,
NULL,
cmd_last_window_exec,
NULL,
@@ -47,6 +47,6 @@ cmd_last_window_exec(unused void *ptr, struct cmd_ctx *ctx)
else
ctx->error(ctx, "no last window");
- if (!(ctx->flags & CMD_KEY))
- server_write_client(ctx->client, MSG_EXIT, NULL, 0);
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}
diff --git a/cmd-link-window.c b/cmd-link-window.c
index 093c4568..918b0492 100644
--- a/cmd-link-window.c
+++ b/cmd-link-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-link-window.c,v 1.5 2007-11-13 09:53:47 nicm Exp $ */
+/* $Id: cmd-link-window.c,v 1.6 2007-11-16 21:12:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -42,7 +42,7 @@ struct cmd_link_window_data {
const struct cmd_entry cmd_link_window_entry = {
"link-window", "linkw", "[-i index] name index",
- 0,
+ CMD_NOCLIENT,
cmd_link_window_parse,
cmd_link_window_exec,
cmd_link_window_send,
@@ -142,8 +142,8 @@ cmd_link_window_exec(void *ptr, struct cmd_ctx *ctx)
} else
server_status_session(dst);
- if (!(ctx->flags & CMD_KEY))
- server_write_client(ctx->client, MSG_EXIT, NULL, 0);
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}
void
diff --git a/cmd-list-clients.c b/cmd-list-clients.c
index 2ca94896..0713e258 100644
--- a/cmd-list-clients.c
+++ b/cmd-list-clients.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-list-clients.c,v 1.1 2007-10-23 09:36:19 nicm Exp $ */
+/* $Id: cmd-list-clients.c,v 1.2 2007-11-16 21:12:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -32,7 +32,7 @@ void cmd_list_clients_exec(void *, struct cmd_ctx *);
const struct cmd_entry cmd_list_clients_entry = {
"list-clients", "lsc", "",
- CMD_NOSESSION,
+ CMD_NOCLIENT|CMD_NOSESSION,
NULL,
cmd_list_clients_exec,
NULL,
@@ -55,6 +55,6 @@ cmd_list_clients_exec(unused void *ptr, struct cmd_ctx *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);
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}
diff --git a/cmd-list-keys.c b/cmd-list-keys.c
index c4cc6180..f4bb6bf1 100644
--- a/cmd-list-keys.c
+++ b/cmd-list-keys.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-list-keys.c,v 1.4 2007-11-13 09:53:47 nicm Exp $ */
+/* $Id: cmd-list-keys.c,v 1.5 2007-11-16 21:12:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -31,7 +31,7 @@ void cmd_list_keys_exec(void *, struct cmd_ctx *);
const struct cmd_entry cmd_list_keys_entry = {
"list-keys", "lsk", "",
- CMD_NOSESSION,
+ CMD_NOCLIENT|CMD_NOSESSION,
NULL,
cmd_list_keys_exec,
NULL,
@@ -53,6 +53,6 @@ cmd_list_keys_exec(unused void *ptr, struct cmd_ctx *ctx)
ctx->print(ctx, "%11s: %s", key, bd->cmd->entry->name);
}
- if (!(ctx->flags & CMD_KEY))
- server_write_client(ctx->client, MSG_EXIT, NULL, 0);
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}
diff --git a/cmd-list-sessions.c b/cmd-list-sessions.c
index 4fc102cf..8b9fd201 100644
--- a/cmd-list-sessions.c
+++ b/cmd-list-sessions.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-list-sessions.c,v 1.8 2007-11-13 09:53:47 nicm Exp $ */
+/* $Id: cmd-list-sessions.c,v 1.9 2007-11-16 21:12:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -32,7 +32,7 @@ void cmd_list_sessions_exec(void *, struct cmd_ctx *);
const struct cmd_entry cmd_list_sessions_entry = {
"list-sessions", "ls", "",
- CMD_NOSESSION,
+ CMD_NOCLIENT|CMD_NOSESSION,
NULL,
cmd_list_sessions_exec,
NULL,
@@ -63,6 +63,6 @@ cmd_list_sessions_exec(unused void *ptr, struct cmd_ctx *ctx)
" (created %s) [%ux%u]", s->name, n, tim, s->sx, s->sy);
}
- if (!(ctx->flags & CMD_KEY))
- server_write_client(ctx->client, MSG_EXIT, NULL, 0);
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}
diff --git a/cmd-list-windows.c b/cmd-list-windows.c
index ab80d3b3..1340a7ae 100644
--- a/cmd-list-windows.c
+++ b/cmd-list-windows.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-list-windows.c,v 1.7 2007-11-13 09:53:47 nicm Exp $ */
+/* $Id: cmd-list-windows.c,v 1.8 2007-11-16 21:12:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -31,7 +31,7 @@ void cmd_list_windows_exec(void *, struct cmd_ctx *);
const struct cmd_entry cmd_list_windows_entry = {
"list-windows", "lsw", NULL,
- 0,
+ CMD_NOCLIENT,
NULL,
cmd_list_windows_exec,
NULL,
@@ -52,6 +52,6 @@ cmd_list_windows_exec(unused void *ptr, struct cmd_ctx *ctx)
w->screen.sx, w->screen.sy);
}
- if (!(ctx->flags & CMD_KEY))
- server_write_client(ctx->client, MSG_EXIT, NULL, 0);
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}
diff --git a/cmd-new-session.c b/cmd-new-session.c
index 4122e539..75574f41 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-new-session.c,v 1.16 2007-11-13 09:53:47 nicm Exp $ */
+/* $Id: cmd-new-session.c,v 1.17 2007-11-16 21:12:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -42,7 +42,7 @@ struct cmd_new_session_data {
const struct cmd_entry cmd_new_session_entry = {
"new-session", "new",
"[-d] [-s session-name] [-n window-name] [command]",
- CMD_STARTSERVER|CMD_NOSESSION|CMD_CANTNEST,
+ CMD_STARTSERVER|CMD_NOCLIENT|CMD_NOSESSION|CMD_CANTNEST,
cmd_new_session_parse,
cmd_new_session_exec,
cmd_new_session_send,
@@ -110,7 +110,7 @@ cmd_new_session_exec(void *ptr, struct cmd_ctx *ctx)
if (ctx->flags & CMD_KEY)
return;
- c = ctx->client;
+ c = ctx->cmdclient;
if (!data->flag_detached && !(c->flags & CLIENT_TERMINAL)) {
ctx->error(ctx, "not a terminal");
return;
diff --git a/cmd-new-window.c b/cmd-new-window.c
index ebb434c9..730c0293 100644
--- a/cmd-new-window.c
+++ b/cmd-new-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-new-window.c,v 1.12 2007-11-13 09:53:47 nicm Exp $ */
+/* $Id: cmd-new-window.c,v 1.13 2007-11-16 21:12:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -42,7 +42,7 @@ struct cmd_new_window_data {
const struct cmd_entry cmd_new_window_entry = {
"new-window", "neww", "[-d] [-i index] [-n name] [command]",
- 0,
+ CMD_NOCLIENT,
cmd_new_window_parse,
cmd_new_window_exec,
cmd_new_window_send,
@@ -129,8 +129,8 @@ cmd_new_window_exec(void *ptr, struct cmd_ctx *ctx)
} else
server_status_session(ctx->session);
- if (!(ctx->flags & CMD_KEY))
- server_write_client(ctx->client, MSG_EXIT, NULL, 0);
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}
void
diff --git a/cmd-next-window.c b/cmd-next-window.c
index 773f2b36..8a807714 100644
--- a/cmd-next-window.c
+++ b/cmd-next-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-next-window.c,v 1.4 2007-11-13 09:53:47 nicm Exp $ */
+/* $Id: cmd-next-window.c,v 1.5 2007-11-16 21:12:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -31,7 +31,7 @@ void cmd_next_window_exec(void *, struct cmd_ctx *);
const struct cmd_entry cmd_next_window_entry = {
"next-window", "next", "",
- 0,
+ CMD_NOCLIENT,
NULL,
cmd_next_window_exec,
NULL,
@@ -47,6 +47,6 @@ cmd_next_window_exec(unused void *ptr, struct cmd_ctx *ctx)
else
ctx->error(ctx, "no next window");
- if (!(ctx->flags & CMD_KEY))
- server_write_client(ctx->client, MSG_EXIT, NULL, 0);
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}
diff --git a/cmd-previous-window.c b/cmd-previous-window.c
index 640cddf7..cdf0b7d8 100644
--- a/cmd-previous-window.c
+++ b/cmd-previous-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-previous-window.c,v 1.4 2007-11-13 09:53:47 nicm Exp $ */
+/* $Id: cmd-previous-window.c,v 1.5 2007-11-16 21:12:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -31,7 +31,7 @@ void cmd_previous_window_exec(void *, struct cmd_ctx *);
const struct cmd_entry cmd_previous_window_entry = {
"previous-window", "prev", "",
- 0,
+ CMD_NOCLIENT,
NULL,
cmd_previous_window_exec,
NULL,
@@ -47,6 +47,6 @@ cmd_previous_window_exec(unused void *ptr, struct cmd_ctx *ctx)
else
ctx->error(ctx, "no previous window");
- if (!(ctx->flags & CMD_KEY))
- server_write_client(ctx->client, MSG_EXIT, NULL, 0);
+ if (ctx->cmdclient != NULL)
+ server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
}
diff --git a/cmd-refresh-client.c b/cmd-refresh-client.c
new file mode 100644
index 00000000..ba2ce5bf
--- /dev/null
+++ b/cmd-refresh-client.c
@@ -0,0 +1,48 @@
+/* $Id: cmd-refresh-client.c,v 1.1 2007-11-16 21:12:31 nicm Exp $ */
+
+/*
+ * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
+ *
+ * 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 <sys/types.h>
+
+#include <getopt.h>
+
+#include "tmux.h"
+
+/*
+ * Refresh client.
+ */
+
+void cmd_refresh_client_exec(void *, struct cmd_ctx *);
+
+const struct cmd_entry cmd_refresh_client_entry = {
+ "refresh-cl