mirror of
https://github.com/tmate-io/tmate.git
synced 2025-02-22 21:31:16 +01:00
Add -c option to specify client, and move detach/refresh to client rather than session.
This commit is contained in:
parent
86b73cec72
commit
b359f9b594
6
CHANGES
6
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 $
|
||||
|
@ -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
|
||||
|
||||
|
6
Makefile
6
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
|
||||
|
||||
|
7
TODO
7
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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
48
cmd-detach-client.c
Normal file
48
cmd-detach-client.c
Normal file
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
48
cmd-refresh-client.c
Normal file
48
cmd-refresh-client.c
Normal file
@ -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-client", "refresh", "",
|
||||
0,
|
||||
NULL,
|
||||
cmd_refresh_client_exec,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
void
|
||||
cmd_refresh_client_exec(unused void *ptr, struct cmd_ctx *ctx)
|
||||
{
|
||||
server_redraw_client(ctx->client);
|
||||
|
||||
if (ctx->cmdclient != NULL)
|
||||
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
|
||||
}
|
@ -1,130 +0,0 @@
|
||||
/* $Id: cmd-refresh-session.c,v 1.2 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"
|
||||
|
||||
/*
|
||||
* Refresh session. If called with -a refresh all clients attached to specified
|
||||
* session, otherwise refresh current session on key press only.
|
||||
*/
|
||||
|
||||
int cmd_refresh_session_parse(void **, int, char **, char **);
|
||||
void cmd_refresh_session_exec(void *, struct cmd_ctx *);
|
||||
void cmd_refresh_session_send(void *, struct buffer *);
|
||||
void cmd_refresh_session_recv(void **, struct buffer *);
|
||||
void cmd_refresh_session_free(void *);
|
||||
|
||||
struct cmd_refresh_session_data {
|
||||
int flag_all;
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_refresh_session_entry = {
|
||||
"refresh-session", "refresh", "[-a]",
|
||||
0,
|
||||
cmd_refresh_session_parse,
|
||||
cmd_refresh_session_exec,
|
||||
cmd_refresh_session_send,
|
||||
cmd_refresh_session_recv,
|
||||
cmd_refresh_session_free
|
||||
};
|
||||
|
||||
int
|
||||
cmd_refresh_session_parse(void **ptr, int argc, char **argv, char **cause)
|
||||
{
|
||||
struct cmd_refresh_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_refresh_session_entry.name, cmd_refresh_session_entry.usage);
|
||||
|
||||
cmd_refresh_session_free(data);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_refresh_session_exec(void *ptr, struct cmd_ctx *ctx)
|
||||
{
|
||||
struct cmd_refresh_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_redraw_client(c);
|
||||
}
|
||||
} else if (ctx->flags & CMD_KEY)
|
||||
server_redraw_client(ctx->client);
|
||||
|
||||
if (!(ctx->flags & CMD_KEY))
|
||||
server_write_client(ctx->client, MSG_EXIT, NULL, 0);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_refresh_session_send(void *ptr, struct buffer *b)
|
||||
{
|
||||
struct cmd_refresh_session_data *data = ptr;
|
||||
|
||||
buffer_write(b, data, sizeof *data);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_refresh_session_recv(void **ptr, struct buffer *b)
|
||||
{
|
||||
struct cmd_refresh_session_data *data;
|
||||
|
||||
*ptr = data = xmalloc(sizeof *data);
|
||||
buffer_read(b, data, sizeof *data);
|
||||
}
|
||||
|
||||
void
|
||||
cmd_refresh_session_free(void *ptr)
|
||||
{
|
||||
struct cmd_refresh_session_data *data = ptr;
|
||||
|
||||
xfree(data);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-rename-session.c,v 1.2 2007-11-13 09:53:47 nicm Exp $ */
|
||||
/* $Id: cmd-rename-session.c,v 1.3 2007-11-16 21:12:31 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -39,7 +39,7 @@ struct cmd_rename_session_data {
|
||||
|
||||
const struct cmd_entry cmd_rename_session_entry = {
|
||||
"rename-session", "rename", "new-name",
|
||||
0,
|
||||
CMD_NOCLIENT,
|
||||
cmd_rename_session_parse,
|
||||
cmd_rename_session_exec,
|
||||
cmd_rename_session_send,
|
||||
@ -90,8 +90,8 @@ cmd_rename_session_exec(void *ptr, struct cmd_ctx *ctx)
|
||||
xfree(ctx->session->name);
|
||||
ctx->session->name = xstrdup(data->newname);
|
||||
|
||||
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
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-rename-window.c,v 1.12 2007-11-13 09:53:47 nicm Exp $ */
|
||||
/* $Id: cmd-rename-window.c,v 1.13 2007-11-16 21:12:31 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -40,7 +40,7 @@ struct cmd_rename_window_data {
|
||||
|
||||
const struct cmd_entry cmd_rename_window_entry = {
|
||||
"rename-window", "renamew", "[-i index] new-name",
|
||||
0,
|
||||
CMD_NOCLIENT,
|
||||
cmd_rename_window_parse,
|
||||
cmd_rename_window_exec,
|
||||
cmd_rename_window_send,
|
||||
@ -111,8 +111,8 @@ cmd_rename_window_exec(void *ptr, struct cmd_ctx *ctx)
|
||||
|
||||
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
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-select-window.c,v 1.9 2007-11-13 09:53:47 nicm Exp $ */
|
||||
/* $Id: cmd-select-window.c,v 1.10 2007-11-16 21:12:31 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -39,7 +39,7 @@ struct cmd_select_window_data {
|
||||
|
||||
const struct cmd_entry cmd_select_window_entry = {
|
||||
"select-window", "selectw", "index",
|
||||
0,
|
||||
CMD_NOCLIENT,
|
||||
cmd_select_window_parse,
|
||||
cmd_select_window_exec,
|
||||
cmd_select_window_send,
|
||||
@ -117,8 +117,8 @@ cmd_select_window_exec(void *ptr, struct cmd_ctx *ctx)
|
||||
break;
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-send-prefix.c,v 1.4 2007-11-13 09:53:47 nicm Exp $ */
|
||||
/* $Id: cmd-send-prefix.c,v 1.5 2007-11-16 21:12:31 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -42,11 +42,9 @@ const struct cmd_entry cmd_send_prefix_entry = {
|
||||
void
|
||||
cmd_send_prefix_exec(unused void *ptr, struct cmd_ctx *ctx)
|
||||
{
|
||||
struct window *w = ctx->client->session->curw->window;
|
||||
input_translate_key(
|
||||
ctx->client->session->curw->window->out, prefix_key);
|
||||
|
||||
if (ctx->flags & CMD_KEY)
|
||||
input_translate_key(w->out, prefix_key);
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-set-option.c,v 1.12 2007-11-13 09:53:47 nicm Exp $ */
|
||||
/* $Id: cmd-set-option.c,v 1.13 2007-11-16 21:12:31 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -41,7 +41,7 @@ struct cmd_set_option_data {
|
||||
|
||||
const struct cmd_entry cmd_set_option_entry = {
|
||||
"set-option", "set", "option value",
|
||||
CMD_NOSESSION,
|
||||
CMD_NOCLIENT|CMD_NOSESSION,
|
||||
cmd_set_option_parse,
|
||||
cmd_set_option_exec,
|
||||
cmd_set_option_send,
|
||||
@ -198,8 +198,8 @@ cmd_set_option_exec(void *ptr, unused struct cmd_ctx *ctx)
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-swap-window.c,v 1.2 2007-11-13 09:53:47 nicm Exp $ */
|
||||
/* $Id: cmd-swap-window.c,v 1.3 2007-11-16 21:12:31 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -42,7 +42,7 @@ struct cmd_swap_window_data {
|
||||
|
||||
const struct cmd_entry cmd_swap_window_entry = {
|
||||
"swap-window", "swapw", "[-i index] name index",
|
||||
0,
|
||||
CMD_NOCLIENT,
|
||||
cmd_swap_window_parse,
|
||||
cmd_swap_window_exec,
|
||||
cmd_swap_window_send,
|
||||
@ -155,8 +155,8 @@ cmd_swap_window_exec(void *ptr, struct cmd_ctx *ctx)
|
||||
if (src != dst)
|
||||
server_redraw_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
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-unbind-key.c,v 1.6 2007-11-13 09:53:47 nicm Exp $ */
|
||||
/* $Id: cmd-unbind-key.c,v 1.7 2007-11-16 21:12:31 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -38,7 +38,7 @@ struct cmd_unbind_key_data {
|
||||
|
||||
const struct cmd_entry cmd_unbind_key_entry = {
|
||||
"unbind-key", "unbind", "key",
|
||||
CMD_NOSESSION,
|
||||
CMD_NOCLIENT|CMD_NOSESSION,
|
||||
cmd_unbind_key_parse,
|
||||
cmd_unbind_key_exec,
|
||||
cmd_unbind_key_send,
|
||||
@ -91,8 +91,8 @@ cmd_unbind_key_exec(void *ptr, unused struct cmd_ctx *ctx)
|
||||
|
||||
key_bindings_remove(data->key);
|
||||
|
||||
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
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-unlink-window.c,v 1.3 2007-11-13 09:53:47 nicm Exp $ */
|
||||
/* $Id: cmd-unlink-window.c,v 1.4 2007-11-16 21:12:31 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -38,8 +38,8 @@ struct cmd_unlink_window_data {
|
||||
};
|
||||
|
||||
const struct cmd_entry cmd_unlink_window_entry = {
|
||||
"unlink-window", "unlinkw", "[-i index",
|
||||
0,
|
||||
"unlink-window", "unlinkw", "[-i index]",
|
||||
CMD_NOCLIENT,
|
||||
cmd_unlink_window_parse,
|
||||
cmd_unlink_window_exec,
|
||||
cmd_unlink_window_send,
|
||||
@ -128,8 +128,8 @@ cmd_unlink_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
|
||||
|
6
cmd.c
6
cmd.c
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd.c,v 1.27 2007-11-16 13:23:59 nicm Exp $ */
|
||||
/* $Id: cmd.c,v 1.28 2007-11-16 21:12:31 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -26,7 +26,7 @@
|
||||
const struct cmd_entry *cmd_table[] = {
|
||||
&cmd_attach_session_entry,
|
||||
&cmd_bind_key_entry,
|
||||
&cmd_detach_session_entry,
|
||||
&cmd_detach_client_entry,
|
||||
&cmd_has_session_entry,
|
||||
&cmd_kill_session_entry,
|
||||
&cmd_kill_window_entry,
|
||||
@ -40,7 +40,7 @@ const struct cmd_entry *cmd_table[] = {
|
||||
&cmd_new_window_entry,
|
||||
&cmd_next_window_entry,
|
||||
&cmd_previous_window_entry,
|
||||
&cmd_refresh_session_entry,
|
||||
&cmd_refresh_client_entry,
|
||||
&cmd_rename_session_entry,
|
||||
&cmd_rename_window_entry,
|
||||
&cmd_select_window_entry,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: key-bindings.c,v 1.12 2007-10-26 12:29:07 nicm Exp $ */
|
||||
/* $Id: key-bindings.c,v 1.13 2007-11-16 21:12:31 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -79,8 +79,8 @@ key_bindings_init(void)
|
||||
const struct cmd_entry *entry;
|
||||
void (*fn)(void **, int);
|
||||
} table[] = {
|
||||
{ 'D', &cmd_detach_session_entry, NULL },
|
||||
{ 'd', &cmd_detach_session_entry, NULL },
|
||||
{ 'D', &cmd_detach_client_entry, NULL },
|
||||
{ 'd', &cmd_detach_client_entry, NULL },
|
||||
{ 'S', &cmd_list_sessions_entry, NULL },
|
||||
{ 's', &cmd_list_sessions_entry, NULL },
|
||||
{ 'W', &cmd_list_windows_entry, NULL },
|
||||
@ -105,15 +105,10 @@ key_bindings_init(void)
|
||||
{ '7', &cmd_select_window_entry, cmd_select_window_default },
|
||||
{ '8', &cmd_select_window_entry, cmd_select_window_default },
|
||||
{ '9', &cmd_select_window_entry, cmd_select_window_default },
|
||||
{ 'R', &cmd_refresh_session_entry, NULL },
|
||||
{ 'r', &cmd_refresh_session_entry, NULL },
|
||||
{ 'R', &cmd_refresh_client_entry, NULL },
|
||||
{ 'r', &cmd_refresh_client_entry, NULL },
|
||||
{ '&', &cmd_kill_window_entry, NULL },
|
||||
{ META, &cmd_send_prefix_entry, NULL },
|
||||
/*
|
||||
{ 'I', &cmd_windo_info_entry },
|
||||
{ 'i', &cmd_window_info_entry },
|
||||
{ META, &cmd_meta_entry_entry },
|
||||
*/
|
||||
};
|
||||
u_int i;
|
||||
struct cmd *cmd;
|
||||
@ -164,7 +159,7 @@ key_bindings_error(struct cmd_ctx *ctx, const char *fmt, ...)
|
||||
void
|
||||
key_bindings_print(struct cmd_ctx *ctx, const char *fmt, ...)
|
||||
{
|
||||
struct client *c = ctx->client;
|
||||
struct client *c = ctx->cmdclient;
|
||||
struct hdr hdr;
|
||||
va_list ap;
|
||||
char *msg;
|
||||
@ -219,11 +214,12 @@ key_bindings_dispatch(int key, struct client *c)
|
||||
return;
|
||||
|
||||
ctx.session = c->session;
|
||||
ctx.client = c;
|
||||
|
||||
ctx.error = key_bindings_error;
|
||||
ctx.print = key_bindings_print;
|
||||
|
||||
ctx.client = c;
|
||||
ctx.cmdclient = NULL;
|
||||
ctx.flags = CMD_KEY;
|
||||
|
||||
cmd_exec(bd->cmd, &ctx);
|
||||
|
58
server-msg.c
58
server-msg.c
@ -1,4 +1,4 @@
|
||||
/* $Id: server-msg.c,v 1.30 2007-10-26 12:29:07 nicm Exp $ */
|
||||
/* $Id: server-msg.c,v 1.31 2007-11-16 21:12:31 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -84,7 +84,7 @@ server_msg_fn_command_error(struct cmd_ctx *ctx, const char *fmt, ...)
|
||||
xvasprintf(&msg, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
server_write_client(ctx->client, MSG_ERROR, msg, strlen(msg));
|
||||
server_write_client(ctx->cmdclient, MSG_ERROR, msg, strlen(msg));
|
||||
xfree(msg);
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ server_msg_fn_command_print(struct cmd_ctx *ctx, const char *fmt, ...)
|
||||
xvasprintf(&msg, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
server_write_client(ctx->client, MSG_PRINT, msg, strlen(msg));
|
||||
server_write_client(ctx->cmdclient, MSG_PRINT, msg, strlen(msg));
|
||||
xfree(msg);
|
||||
}
|
||||
|
||||
@ -108,12 +108,14 @@ server_msg_fn_command(struct hdr *hdr, struct client *c)
|
||||
struct msg_command_data data;
|
||||
struct cmd_ctx ctx;
|
||||
struct cmd *cmd;
|
||||
char *name, *cause;
|
||||
char *name, *client, *cause;
|
||||
u_int i;
|
||||
|
||||
if (hdr->size < sizeof data)
|
||||
fatalx("bad MSG_COMMAND size");
|
||||
buffer_read(c->in, &data, sizeof data);
|
||||
name = cmd_recv_string(c->in);
|
||||
client = cmd_recv_string(c->in);
|
||||
|
||||
cmd = cmd_recv(c->in);
|
||||
log_debug("got command %s from client %d", cmd->entry->name, c->fd);
|
||||
@ -121,21 +123,53 @@ server_msg_fn_command(struct hdr *hdr, struct client *c)
|
||||
ctx.error = server_msg_fn_command_error;
|
||||
ctx.print = server_msg_fn_command_print;
|
||||
|
||||
ctx.client = c;
|
||||
ctx.cmdclient = c;
|
||||
ctx.flags = 0;
|
||||
|
||||
if (data.pid != -1 && (cmd->entry->flags & CMD_CANTNEST)) {
|
||||
server_msg_fn_command_error(&ctx, "sessions should be nested "
|
||||
"with care. unset $TMUX to force");
|
||||
server_msg_fn_command_error(&ctx, "sessions "
|
||||
"should be nested with care. unset $TMUX to force");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (cmd->entry->flags & CMD_NOSESSION)
|
||||
ctx.session = NULL;
|
||||
else {
|
||||
ctx.session = server_extract_session(&data, name, &cause);
|
||||
ctx.client = NULL;
|
||||
if (cmd->entry->flags & CMD_NOCLIENT) {
|
||||
if (client != NULL) {
|
||||
server_msg_fn_command_error(&ctx,
|
||||
"%s: cannot specify a client", cmd->entry->name);
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
if (client == NULL) {
|
||||
server_msg_fn_command_error(&ctx, "%s: must "
|
||||
"specify a client: %s", cmd->entry->name, client);
|
||||
goto out;
|
||||
}
|
||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||
/* XXX fnmatch, multi clients etc */
|
||||
c = ARRAY_ITEM(&clients, i);
|
||||
if (strcmp(client, c->tty) == 0)
|
||||
ctx.client = c;
|
||||
}
|
||||
if (ctx.client == NULL) {
|
||||
server_msg_fn_command_error(&ctx, "%s: "
|
||||
"client not found: %s", cmd->entry->name, client);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
ctx.session = server_extract_session(&data, name, &cause);
|
||||
if (cmd->entry->flags & CMD_NOSESSION) {
|
||||
if (ctx.session != NULL) {
|
||||
server_msg_fn_command_error(&ctx,
|
||||
"%s: cannot specify a session", cmd->entry->name);
|
||||
goto out;
|
||||
} else
|
||||
xfree(cause);
|
||||
} else {
|
||||
if (ctx.session == NULL) {
|
||||
server_msg_fn_command_error(&ctx, "%s", cause);
|
||||
server_msg_fn_command_error(
|
||||
&ctx, "%s: %s", cmd->entry->name, cause);
|
||||
xfree(cause);
|
||||
goto out;
|
||||
}
|
||||
|
29
tmux.1
29
tmux.1
@ -1,4 +1,4 @@
|
||||
.\" $Id: tmux.1,v 1.13 2007-11-12 20:46:46 nicm Exp $
|
||||
.\" $Id: tmux.1,v 1.14 2007-11-16 21:12:31 nicm Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
.\"
|
||||
@ -24,6 +24,7 @@
|
||||
.Nm tmux
|
||||
.Bk -words
|
||||
.Op Fl vV
|
||||
.Op Fl c Ar client-tty
|
||||
.Op Fl S Ar socket-path
|
||||
.Op Fl s Ar session-name
|
||||
.Ar command
|
||||
@ -50,8 +51,14 @@ Communication takes place through a socket, by default placed in
|
||||
.Pp
|
||||
The options are as follows:
|
||||
.Bl -tag -width "XXXXXXXXXXXX"
|
||||
.It Fl c Ar client-tty
|
||||
Apply command to the client on the given tty.
|
||||
Clients may be listed with the
|
||||
.Ic list-clients
|
||||
command (see below).
|
||||
This option does not apply to all commands.
|
||||
.It Fl S Ar socket-path
|
||||
This specifies an alternative path to the server socket.
|
||||
Specify an alternative path to the server socket.
|
||||
The default is
|
||||
.Pa /tmp/tmux-UID ,
|
||||
where
|
||||
@ -138,13 +145,11 @@ Bind key
|
||||
.Ar key
|
||||
to
|
||||
.Ar command .
|
||||
.It Xo Ic detach-session
|
||||
.Op Fl a
|
||||
.It Xo Ic detach-client
|
||||
.Xc
|
||||
.D1 (alias: Ic detach )
|
||||
Detach the current client if bound to a key; otherwise, if
|
||||
.Fl a
|
||||
is given, detach all clients attached to the session.
|
||||
Detach the current client if bound to a key, or the specified client with
|
||||
.Fl c .
|
||||
.It Xo Ic has-session
|
||||
.Xc
|
||||
.D1 (alias: Ic has )
|
||||
@ -255,14 +260,12 @@ Move to the next window in the session.
|
||||
.Xc
|
||||
.D1 (alias: Ic prev )
|
||||
Move to the previous window in the session.
|
||||
.It Xo Ic refresh-session
|
||||
.Op Fl a
|
||||
.It Xo Ic refresh-client
|
||||
.Xc
|
||||
.D1 (alias: Ic refresh )
|
||||
Refresh the display of clients attached to a session.
|
||||
If bound to a key, only the current client is refreshed; otherwise if
|
||||
.Fl a
|
||||
is given, all clients attached to the session is refreshed.
|
||||
Refresh the current client if bound to a key, or a single client if one given
|
||||
with
|
||||
.Fl c .
|
||||
.It Xo Ic rename-session
|
||||
.Ar new-name
|
||||
.Xc
|
||||
|
21
tmux.c
21
tmux.c
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.c,v 1.40 2007-11-12 15:12:08 nicm Exp $ */
|
||||
/* $Id: tmux.c,v 1.41 2007-11-16 21:12:31 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -52,17 +52,19 @@ usage(char **ptr, const char *fmt, ...)
|
||||
char *msg;
|
||||
va_list ap;
|
||||
|
||||
#define USAGE \
|
||||
"usage: %s [-v] [-S socket-path] [-s session-name] [-c client-tty]"
|
||||
if (fmt == NULL) {
|
||||
xasprintf(ptr,
|
||||
"usage: %s [-v] [-S path] command [flags]", __progname);
|
||||
xasprintf(ptr, USAGE " command [flags]", __progname);
|
||||
} else {
|
||||
va_start(ap, fmt);
|
||||
xvasprintf(&msg, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
xasprintf(ptr, "usage: %s [-v] [-S path] %s", __progname, msg);
|
||||
xasprintf(ptr, USAGE " %s", __progname, msg);
|
||||
xfree(msg);
|
||||
}
|
||||
#undef USAGE
|
||||
}
|
||||
|
||||
void
|
||||
@ -173,12 +175,16 @@ main(int argc, char **argv)
|
||||
struct hdr hdr;
|
||||
const char *shell;
|
||||
struct passwd *pw;
|
||||
char *path, rpath[MAXPATHLEN], *cause, *name;
|
||||
char *client, *path, *name, *cause;
|
||||
char rpath[MAXPATHLEN];
|
||||
int n, opt;
|
||||
|
||||
path = name = NULL;
|
||||
while ((opt = getopt(argc, argv, "S:s:vV")) != EOF) {
|
||||
client = path = name = NULL;
|
||||
while ((opt = getopt(argc, argv, "c:S:s:vV")) != EOF) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
client = xstrdup(optarg);
|
||||
break;
|
||||
case 'S':
|
||||
path = xstrdup(optarg);
|
||||
break;
|
||||
@ -244,6 +250,7 @@ main(int argc, char **argv)
|
||||
exit(1);
|
||||
b = buffer_create(BUFSIZ);
|
||||
cmd_send_string(b, name);
|
||||
cmd_send_string(b, client);
|
||||
cmd_send(cmd, b);
|
||||
cmd_free(cmd);
|
||||
|
||||
|
11
tmux.h
11
tmux.h
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.h,v 1.79 2007-11-12 15:12:08 nicm Exp $ */
|
||||
/* $Id: tmux.h,v 1.80 2007-11-16 21:12:31 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -488,6 +488,8 @@ struct client_ctx {
|
||||
|
||||
/* Key/command line command. */
|
||||
struct cmd_ctx {
|
||||
struct client *cmdclient;
|
||||
|
||||
struct client *client;
|
||||
struct session *session;
|
||||
|
||||
@ -505,7 +507,8 @@ struct cmd_entry {
|
||||
|
||||
#define CMD_STARTSERVER 0x1
|
||||
#define CMD_NOSESSION 0x2
|
||||
#define CMD_CANTNEST 0x4
|
||||
#define CMD_NOCLIENT 0x4
|
||||
#define CMD_CANTNEST 0x8
|
||||
int flags;
|
||||
|
||||
int (*parse)(void **, int, char **, char **);
|
||||
@ -569,7 +572,7 @@ void cmd_send_string(struct buffer *, const char *);
|
||||
char *cmd_recv_string(struct buffer *);
|
||||
extern const struct cmd_entry cmd_attach_session_entry;
|
||||
extern const struct cmd_entry cmd_bind_key_entry;
|
||||
extern const struct cmd_entry cmd_detach_session_entry;
|
||||
extern const struct cmd_entry cmd_detach_client_entry;
|
||||
extern const struct cmd_entry cmd_has_session_entry;
|
||||
extern const struct cmd_entry cmd_kill_session_entry;
|
||||
extern const struct cmd_entry cmd_kill_window_entry;
|
||||
@ -583,7 +586,7 @@ extern const struct cmd_entry cmd_new_session_entry;
|
||||
extern const struct cmd_entry cmd_new_window_entry;
|
||||
extern const struct cmd_entry cmd_next_window_entry;
|
||||
extern const struct cmd_entry cmd_previous_window_entry;
|
||||
extern const struct cmd_entry cmd_refresh_session_entry;
|
||||
extern const struct cmd_entry cmd_refresh_client_entry;
|
||||
extern const struct cmd_entry cmd_rename_session_entry;
|
||||
extern const struct cmd_entry cmd_rename_window_entry;
|
||||
extern const struct cmd_entry cmd_select_window_entry;
|
||||
|
Loading…
Reference in New Issue
Block a user