From f91e7bfd381826eb88edacc7b5766c262a71b033 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Tue, 3 Jun 2008 05:35:51 +0000 Subject: [PATCH] If no command is specified, assume new-session. --- CHANGES | 4 ++- cmd-attach-session.c | 5 +-- cmd-bind-key.c | 5 +-- cmd-copy-mode.c | 5 +-- cmd-detach-client.c | 5 +-- cmd-has-session.c | 5 +-- cmd-kill-server.c | 3 +- cmd-kill-session.c | 5 +-- cmd-kill-window.c | 5 +-- cmd-last-window.c | 5 +-- cmd-link-window.c | 5 +-- cmd-list-clients.c | 3 +- cmd-list-keys.c | 3 +- cmd-list-sessions.c | 4 ++- cmd-list-windows.c | 5 +-- cmd-new-session.c | 29 ++++++++++------- cmd-new-window.c | 31 +++++++++++------- cmd-next-window.c | 5 +-- cmd-paste-buffer.c | 5 +-- cmd-previous-window.c | 5 +-- cmd-refresh-client.c | 5 +-- cmd-rename-session.c | 5 +-- cmd-rename-window.c | 5 +-- cmd-scroll-mode.c | 5 +-- cmd-select-window.c | 15 ++++----- cmd-send-keys.c | 5 +-- cmd-send-prefix.c | 5 +-- cmd-set-option.c | 5 +-- cmd-start-server.c | 3 +- cmd-swap-window.c | 5 +-- cmd-switch-client.c | 5 +-- cmd-unbind-key.c | 5 +-- cmd-unlink-window.c | 6 ++-- key-bindings.c | 73 +++++++++++++++++++++---------------------- tmux.1 | 18 +++++++++-- tmux.c | 12 ++++--- tmux.h | 4 +-- 37 files changed, 189 insertions(+), 134 deletions(-) diff --git a/CHANGES b/CHANGES index 817edebd..11a74aa2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,7 @@ 03 June 2008 +* If no command is specified, assume new-session. As a byproduct, clean up + command default values into seperate init functions. * kill-server command. 02 June 2008 @@ -372,4 +374,4 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.99 2008-06-03 05:10:38 nicm Exp $ +$Id: CHANGES,v 1.100 2008-06-03 05:35:50 nicm Exp $ diff --git a/cmd-attach-session.c b/cmd-attach-session.c index f11a93f1..04b6c349 100644 --- a/cmd-attach-session.c +++ b/cmd-attach-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-attach-session.c,v 1.13 2008-06-02 21:08:36 nicm Exp $ */ +/* $Id: cmd-attach-session.c,v 1.14 2008-06-03 05:35:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -45,7 +45,8 @@ const struct cmd_entry cmd_attach_session_entry = { cmd_attach_session_exec, cmd_attach_session_send, cmd_attach_session_recv, - cmd_attach_session_free + cmd_attach_session_free, + NULL }; int diff --git a/cmd-bind-key.c b/cmd-bind-key.c index 49535b97..f02c440b 100644 --- a/cmd-bind-key.c +++ b/cmd-bind-key.c @@ -1,4 +1,4 @@ -/* $Id: cmd-bind-key.c,v 1.11 2008-06-02 22:09:49 nicm Exp $ */ +/* $Id: cmd-bind-key.c,v 1.12 2008-06-03 05:35:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -45,7 +45,8 @@ const struct cmd_entry cmd_bind_key_entry = { cmd_bind_key_exec, cmd_bind_key_send, cmd_bind_key_recv, - cmd_bind_key_free + cmd_bind_key_free, + NULL }; int diff --git a/cmd-copy-mode.c b/cmd-copy-mode.c index 20ea5c15..88123043 100644 --- a/cmd-copy-mode.c +++ b/cmd-copy-mode.c @@ -1,4 +1,4 @@ -/* $Id: cmd-copy-mode.c,v 1.7 2008-06-02 22:09:49 nicm Exp $ */ +/* $Id: cmd-copy-mode.c,v 1.8 2008-06-03 05:35:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -34,7 +34,8 @@ const struct cmd_entry cmd_copy_mode_entry = { cmd_copy_mode_exec, cmd_windowonly_send, cmd_windowonly_recv, - cmd_windowonly_free + cmd_windowonly_free, + NULL }; void diff --git a/cmd-detach-client.c b/cmd-detach-client.c index f93df01b..934f948d 100644 --- a/cmd-detach-client.c +++ b/cmd-detach-client.c @@ -1,4 +1,4 @@ -/* $Id: cmd-detach-client.c,v 1.3 2008-06-02 22:09:49 nicm Exp $ */ +/* $Id: cmd-detach-client.c,v 1.4 2008-06-03 05:35:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -34,7 +34,8 @@ const struct cmd_entry cmd_detach_client_entry = { cmd_detach_client_exec, cmd_clientonly_send, cmd_clientonly_recv, - cmd_clientonly_free + cmd_clientonly_free, + NULL }; void diff --git a/cmd-has-session.c b/cmd-has-session.c index 4e34d11e..fade7de7 100644 --- a/cmd-has-session.c +++ b/cmd-has-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-has-session.c,v 1.6 2008-06-02 22:09:49 nicm Exp $ */ +/* $Id: cmd-has-session.c,v 1.7 2008-06-03 05:35:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -34,7 +34,8 @@ const struct cmd_entry cmd_has_session_entry = { cmd_has_session_exec, cmd_sessiononly_send, cmd_sessiononly_recv, - cmd_sessiononly_free + cmd_sessiononly_free, + NULL }; void diff --git a/cmd-kill-server.c b/cmd-kill-server.c index 6d3d8f59..279929da 100644 --- a/cmd-kill-server.c +++ b/cmd-kill-server.c @@ -1,4 +1,4 @@ -/* $Id: cmd-kill-server.c,v 1.1 2008-06-03 05:10:38 nicm Exp $ */ +/* $Id: cmd-kill-server.c,v 1.2 2008-06-03 05:35:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -37,6 +37,7 @@ const struct cmd_entry cmd_kill_server_entry = { cmd_kill_server_exec, NULL, NULL, + NULL, NULL }; diff --git a/cmd-kill-session.c b/cmd-kill-session.c index 63d9ae1c..abca8ca1 100644 --- a/cmd-kill-session.c +++ b/cmd-kill-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-kill-session.c,v 1.7 2008-06-02 22:09:49 nicm Exp $ */ +/* $Id: cmd-kill-session.c,v 1.8 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -37,7 +37,8 @@ const struct cmd_entry cmd_kill_session_entry = { cmd_kill_session_exec, cmd_sessiononly_send, cmd_sessiononly_recv, - cmd_sessiononly_free + cmd_sessiononly_free, + NULL }; void diff --git a/cmd-kill-window.c b/cmd-kill-window.c index b88f5adc..6fd3de3a 100644 --- a/cmd-kill-window.c +++ b/cmd-kill-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-kill-window.c,v 1.10 2008-06-02 22:09:49 nicm Exp $ */ +/* $Id: cmd-kill-window.c,v 1.11 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -34,7 +34,8 @@ const struct cmd_entry cmd_kill_window_entry = { cmd_kill_window_exec, cmd_windowonly_send, cmd_windowonly_recv, - cmd_windowonly_free + cmd_windowonly_free, + NULL }; void diff --git a/cmd-last-window.c b/cmd-last-window.c index d6f4e687..8d55a23c 100644 --- a/cmd-last-window.c +++ b/cmd-last-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-last-window.c,v 1.8 2008-06-02 22:09:49 nicm Exp $ */ +/* $Id: cmd-last-window.c,v 1.9 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -34,7 +34,8 @@ const struct cmd_entry cmd_last_window_entry = { cmd_last_window_exec, cmd_sessiononly_send, cmd_sessiononly_recv, - cmd_sessiononly_free + cmd_sessiononly_free, + NULL }; void diff --git a/cmd-link-window.c b/cmd-link-window.c index 328cb89f..b2ef4486 100644 --- a/cmd-link-window.c +++ b/cmd-link-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-link-window.c,v 1.13 2008-06-02 21:36:51 nicm Exp $ */ +/* $Id: cmd-link-window.c,v 1.14 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -50,7 +50,8 @@ const struct cmd_entry cmd_link_window_entry = { cmd_link_window_exec, cmd_link_window_send, cmd_link_window_recv, - cmd_link_window_free + cmd_link_window_free, + NULL }; int diff --git a/cmd-list-clients.c b/cmd-list-clients.c index e48ab4c1..2abf436e 100644 --- a/cmd-list-clients.c +++ b/cmd-list-clients.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-clients.c,v 1.5 2008-06-03 05:10:38 nicm Exp $ */ +/* $Id: cmd-list-clients.c,v 1.6 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -37,6 +37,7 @@ const struct cmd_entry cmd_list_clients_entry = { cmd_list_clients_exec, NULL, NULL, + NULL, NULL }; diff --git a/cmd-list-keys.c b/cmd-list-keys.c index 2800512e..d31c4ef8 100644 --- a/cmd-list-keys.c +++ b/cmd-list-keys.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-keys.c,v 1.7 2008-06-03 05:10:38 nicm Exp $ */ +/* $Id: cmd-list-keys.c,v 1.8 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -34,6 +34,7 @@ const struct cmd_entry cmd_list_keys_entry = { cmd_list_keys_exec, NULL, NULL, + NULL, NULL }; diff --git a/cmd-list-sessions.c b/cmd-list-sessions.c index d463aa92..fab1064b 100644 --- a/cmd-list-sessions.c +++ b/cmd-list-sessions.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-sessions.c,v 1.11 2008-06-03 05:10:38 nicm Exp $ */ +/* $Id: cmd-list-sessions.c,v 1.12 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -18,6 +18,7 @@ #include +#include #include #include "tmux.h" @@ -35,6 +36,7 @@ const struct cmd_entry cmd_list_sessions_entry = { cmd_list_sessions_exec, NULL, NULL, + NULL, NULL }; diff --git a/cmd-list-windows.c b/cmd-list-windows.c index 7ac60e5e..990e32cc 100644 --- a/cmd-list-windows.c +++ b/cmd-list-windows.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-windows.c,v 1.17 2008-06-02 22:09:49 nicm Exp $ */ +/* $Id: cmd-list-windows.c,v 1.18 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -36,7 +36,8 @@ const struct cmd_entry cmd_list_windows_entry = { cmd_list_windows_exec, cmd_sessiononly_send, cmd_sessiononly_recv, - cmd_sessiononly_free + cmd_sessiononly_free, + NULL }; void diff --git a/cmd-new-session.c b/cmd-new-session.c index 3815f468..66bf6a9f 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-new-session.c,v 1.22 2008-06-02 21:36:51 nicm Exp $ */ +/* $Id: cmd-new-session.c,v 1.23 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -31,6 +31,7 @@ void cmd_new_session_exec(void *, struct cmd_ctx *); void cmd_new_session_send(void *, struct buffer *); void cmd_new_session_recv(void **, struct buffer *); void cmd_new_session_free(void *); +void cmd_new_session_init(void **, int); struct cmd_new_session_data { char *name; @@ -47,9 +48,22 @@ const struct cmd_entry cmd_new_session_entry = { cmd_new_session_exec, cmd_new_session_send, cmd_new_session_recv, - cmd_new_session_free + cmd_new_session_free, + cmd_new_session_init }; +void +cmd_new_session_init(void **ptr, unused int arg) +{ + struct cmd_new_session_data *data; + + *ptr = data = xmalloc(sizeof *data); + data->flag_detached = 0; + data->name = NULL; + data->winname = NULL; + data->cmd = NULL; +} + int cmd_new_session_parse( struct cmd *self, void **ptr, int argc, char **argv, char **cause) @@ -57,11 +71,8 @@ cmd_new_session_parse( struct cmd_new_session_data *data; int opt; - *ptr = data = xmalloc(sizeof *data); - data->flag_detached = 0; - data->name = NULL; - data->winname = NULL; - data->cmd = NULL; + self->entry->init(ptr, 0); + data = *ptr; while ((opt = getopt(argc, argv, "ds:n:")) != EOF) { switch (opt) { @@ -99,15 +110,11 @@ void cmd_new_session_exec(void *ptr, struct cmd_ctx *ctx) { struct cmd_new_session_data *data = ptr; - struct cmd_new_session_data std = { NULL, NULL, NULL, 0 }; struct client *c = ctx->cmdclient; struct session *s; char *cmd, *cause; u_int sx, sy; - if (data == NULL) - data = &std; - if (ctx->flags & CMD_KEY) return; diff --git a/cmd-new-window.c b/cmd-new-window.c index b01a77a7..cb13fd66 100644 --- a/cmd-new-window.c +++ b/cmd-new-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-new-window.c,v 1.17 2008-06-02 21:36:51 nicm Exp $ */ +/* $Id: cmd-new-window.c,v 1.18 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -32,6 +32,7 @@ void cmd_new_window_exec(void *, struct cmd_ctx *); void cmd_new_window_send(void *, struct buffer *); void cmd_new_window_recv(void **, struct buffer *); void cmd_new_window_free(void *); +void cmd_new_window_init(void **, int); struct cmd_new_window_data { char *sname; @@ -49,9 +50,23 @@ const struct cmd_entry cmd_new_window_entry = { cmd_new_window_exec, cmd_new_window_send, cmd_new_window_recv, - cmd_new_window_free + cmd_new_window_free, + cmd_new_window_init }; +void +cmd_new_window_init(void **ptr, unused int arg) +{ + struct cmd_new_window_data *data; + + *ptr = data = xmalloc(sizeof *data); + data->sname = NULL; + data->idx = -1; + data->flag_detached = 0; + data->name = NULL; + data->cmd = NULL; +} + int cmd_new_window_parse( struct cmd *self, void **ptr, int argc, char **argv, char **cause) @@ -60,12 +75,8 @@ cmd_new_window_parse( const char *errstr; int opt; - *ptr = data = xmalloc(sizeof *data); - data->sname = NULL; - data->idx = -1; - data->flag_detached = 0; - data->name = NULL; - data->cmd = NULL; + self->entry->init(ptr, 0); + data = *ptr; while ((opt = getopt(argc, argv, "di:n:s:")) != EOF) { switch (opt) { @@ -111,14 +122,10 @@ void cmd_new_window_exec(void *ptr, struct cmd_ctx *ctx) { struct cmd_new_window_data *data = ptr; - struct cmd_new_window_data std = { NULL, NULL, NULL, -1, 0 }; struct session *s; struct winlink *wl; char *cmd; - if (data == NULL) - data = &std; - cmd = data->cmd; if (cmd == NULL) cmd = default_command; diff --git a/cmd-next-window.c b/cmd-next-window.c index f2c1c214..5c331643 100644 --- a/cmd-next-window.c +++ b/cmd-next-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-next-window.c,v 1.8 2008-06-02 22:09:49 nicm Exp $ */ +/* $Id: cmd-next-window.c,v 1.9 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -34,7 +34,8 @@ const struct cmd_entry cmd_next_window_entry = { cmd_next_window_exec, cmd_sessiononly_send, cmd_sessiononly_recv, - cmd_sessiononly_free + cmd_sessiononly_free, + NULL }; void diff --git a/cmd-paste-buffer.c b/cmd-paste-buffer.c index d0be9c9b..96e0d4f0 100644 --- a/cmd-paste-buffer.c +++ b/cmd-paste-buffer.c @@ -1,4 +1,4 @@ -/* $Id: cmd-paste-buffer.c,v 1.5 2008-06-02 22:09:49 nicm Exp $ */ +/* $Id: cmd-paste-buffer.c,v 1.6 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -36,7 +36,8 @@ const struct cmd_entry cmd_paste_buffer_entry = { cmd_paste_buffer_exec, cmd_windowonly_send, cmd_windowonly_recv, - cmd_windowonly_free + cmd_windowonly_free, + NULL }; void diff --git a/cmd-previous-window.c b/cmd-previous-window.c index 42149f01..2758343f 100644 --- a/cmd-previous-window.c +++ b/cmd-previous-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-previous-window.c,v 1.8 2008-06-02 22:09:49 nicm Exp $ */ +/* $Id: cmd-previous-window.c,v 1.9 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -34,7 +34,8 @@ const struct cmd_entry cmd_previous_window_entry = { cmd_previous_window_exec, cmd_sessiononly_send, cmd_sessiononly_recv, - cmd_sessiononly_free + cmd_sessiononly_free, + NULL }; void diff --git a/cmd-refresh-client.c b/cmd-refresh-client.c index d1ecebb2..90df0ea5 100644 --- a/cmd-refresh-client.c +++ b/cmd-refresh-client.c @@ -1,4 +1,4 @@ -/* $Id: cmd-refresh-client.c,v 1.3 2008-06-02 22:09:49 nicm Exp $ */ +/* $Id: cmd-refresh-client.c,v 1.4 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -34,7 +34,8 @@ const struct cmd_entry cmd_refresh_client_entry = { cmd_refresh_client_exec, cmd_clientonly_send, cmd_clientonly_recv, - cmd_clientonly_free + cmd_clientonly_free, + NULL }; void diff --git a/cmd-rename-session.c b/cmd-rename-session.c index 7007350b..ed64c98f 100644 --- a/cmd-rename-session.c +++ b/cmd-rename-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-rename-session.c,v 1.6 2008-06-02 21:08:36 nicm Exp $ */ +/* $Id: cmd-rename-session.c,v 1.7 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -46,7 +46,8 @@ const struct cmd_entry cmd_rename_session_entry = { cmd_rename_session_exec, cmd_rename_session_send, cmd_rename_session_recv, - cmd_rename_session_free + cmd_rename_session_free, + NULL }; int diff --git a/cmd-rename-window.c b/cmd-rename-window.c index 4ff5f873..ef6657b9 100644 --- a/cmd-rename-window.c +++ b/cmd-rename-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-rename-window.c,v 1.16 2008-06-02 21:08:36 nicm Exp $ */ +/* $Id: cmd-rename-window.c,v 1.17 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -47,7 +47,8 @@ const struct cmd_entry cmd_rename_window_entry = { cmd_rename_window_exec, cmd_rename_window_send, cmd_rename_window_recv, - cmd_rename_window_free + cmd_rename_window_free, + NULL }; int diff --git a/cmd-scroll-mode.c b/cmd-scroll-mode.c index 0688e0a9..dc75de66 100644 --- a/cmd-scroll-mode.c +++ b/cmd-scroll-mode.c @@ -1,4 +1,4 @@ -/* $Id: cmd-scroll-mode.c,v 1.9 2008-06-02 22:09:49 nicm Exp $ */ +/* $Id: cmd-scroll-mode.c,v 1.10 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -34,7 +34,8 @@ const struct cmd_entry cmd_scroll_mode_entry = { cmd_scroll_mode_exec, cmd_windowonly_send, cmd_windowonly_recv, - cmd_windowonly_free + cmd_windowonly_free, + NULL }; void diff --git a/cmd-select-window.c b/cmd-select-window.c index db1894af..a5a4e341 100644 --- a/cmd-select-window.c +++ b/cmd-select-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-select-window.c,v 1.13 2008-06-02 21:08:36 nicm Exp $ */ +/* $Id: cmd-select-window.c,v 1.14 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -32,6 +32,7 @@ void cmd_select_window_exec(void *, struct cmd_ctx *); void cmd_select_window_send(void *, struct buffer *); void cmd_select_window_recv(void **, struct buffer *); void cmd_select_window_free(void *); +void cmd_select_window_init(void **, int); struct cmd_select_window_data { char *sname; @@ -46,22 +47,18 @@ const struct cmd_entry cmd_select_window_entry = { cmd_select_window_exec, cmd_select_window_send, cmd_select_window_recv, - cmd_select_window_free + cmd_select_window_free, + cmd_select_window_init }; -/* - * select-window requires different defaults depending on the key, so this - * fills in the right data. XXX should this be extended to them all and get - * rid of std/NULL rubbish? - */ void -cmd_select_window_default(void **ptr, int key) +cmd_select_window_init(void **ptr, int arg) { struct cmd_select_window_data *data; *ptr = data = xmalloc(sizeof *data); data->sname = NULL; - data->idx = key - '0'; + data->idx = arg - '0'; } int diff --git a/cmd-send-keys.c b/cmd-send-keys.c index ae5e4ef4..22f48323 100644 --- a/cmd-send-keys.c +++ b/cmd-send-keys.c @@ -1,4 +1,4 @@ -/* $Id: cmd-send-keys.c,v 1.5 2008-06-03 05:10:38 nicm Exp $ */ +/* $Id: cmd-send-keys.c,v 1.6 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -46,7 +46,8 @@ const struct cmd_entry cmd_send_keys_entry = { cmd_send_keys_exec, cmd_send_keys_send, cmd_send_keys_recv, - cmd_send_keys_free + cmd_send_keys_free, + NULL }; int diff --git a/cmd-send-prefix.c b/cmd-send-prefix.c index 7a29511a..4a67a434 100644 --- a/cmd-send-prefix.c +++ b/cmd-send-prefix.c @@ -1,4 +1,4 @@ -/* $Id: cmd-send-prefix.c,v 1.9 2008-06-02 22:09:49 nicm Exp $ */ +/* $Id: cmd-send-prefix.c,v 1.10 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -34,7 +34,8 @@ const struct cmd_entry cmd_send_prefix_entry = { cmd_send_prefix_exec, cmd_clientonly_send, cmd_clientonly_recv, - cmd_clientonly_free + cmd_clientonly_free, + NULL }; void diff --git a/cmd-set-option.c b/cmd-set-option.c index 25d47d55..45b8d1bd 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $Id: cmd-set-option.c,v 1.17 2008-06-02 21:08:36 nicm Exp $ */ +/* $Id: cmd-set-option.c,v 1.18 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -47,7 +47,8 @@ const struct cmd_entry cmd_set_option_entry = { cmd_set_option_exec, cmd_set_option_send, cmd_set_option_recv, - cmd_set_option_free + cmd_set_option_free, + NULL }; int diff --git a/cmd-start-server.c b/cmd-start-server.c index cd3c0bb5..7bd89341 100644 --- a/cmd-start-server.c +++ b/cmd-start-server.c @@ -1,4 +1,4 @@ -/* $Id: cmd-start-server.c,v 1.2 2008-06-03 05:10:38 nicm Exp $ */ +/* $Id: cmd-start-server.c,v 1.3 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -34,6 +34,7 @@ const struct cmd_entry cmd_start_server_entry = { cmd_start_server_exec, NULL, NULL, + NULL, NULL }; diff --git a/cmd-swap-window.c b/cmd-swap-window.c index 7f3c9918..d76344c4 100644 --- a/cmd-swap-window.c +++ b/cmd-swap-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-swap-window.c,v 1.6 2008-06-02 21:08:36 nicm Exp $ */ +/* $Id: cmd-swap-window.c,v 1.7 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -49,7 +49,8 @@ const struct cmd_entry cmd_swap_window_entry = { cmd_swap_window_exec, cmd_swap_window_send, cmd_swap_window_recv, - cmd_swap_window_free + cmd_swap_window_free, + NULL }; int diff --git a/cmd-switch-client.c b/cmd-switch-client.c index 24fbf2ab..d823d8b9 100644 --- a/cmd-switch-client.c +++ b/cmd-switch-client.c @@ -1,4 +1,4 @@ -/* $Id: cmd-switch-client.c,v 1.4 2008-06-02 21:08:36 nicm Exp $ */ +/* $Id: cmd-switch-client.c,v 1.5 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -47,7 +47,8 @@ const struct cmd_entry cmd_switch_client_entry = { cmd_switch_client_exec, cmd_switch_client_send, cmd_switch_client_recv, - cmd_switch_client_free + cmd_switch_client_free, + NULL }; int diff --git a/cmd-unbind-key.c b/cmd-unbind-key.c index 9d7e6693..1e660a1d 100644 --- a/cmd-unbind-key.c +++ b/cmd-unbind-key.c @@ -1,4 +1,4 @@ -/* $Id: cmd-unbind-key.c,v 1.10 2008-06-02 21:08:36 nicm Exp $ */ +/* $Id: cmd-unbind-key.c,v 1.11 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -44,7 +44,8 @@ const struct cmd_entry cmd_unbind_key_entry = { cmd_unbind_key_exec, cmd_unbind_key_send, cmd_unbind_key_recv, - cmd_unbind_key_free + cmd_unbind_key_free, + NULL }; int diff --git a/cmd-unlink-window.c b/cmd-unlink-window.c index d44f3d9f..d06203d3 100644 --- a/cmd-unlink-window.c +++ b/cmd-unlink-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-unlink-window.c,v 1.8 2008-06-02 22:09:49 nicm Exp $ */ +/* $Id: cmd-unlink-window.c,v 1.9 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -34,8 +34,8 @@ const struct cmd_entry cmd_unlink_window_entry = { cmd_unlink_window_exec, cmd_windowonly_send, cmd_windowonly_recv, - cmd_windowonly_free - + cmd_windowonly_free, + NULL }; void diff --git a/key-bindings.c b/key-bindings.c index 8754a7a0..f3cb2852 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -1,4 +1,4 @@ -/* $Id: key-bindings.c,v 1.27 2008-06-02 18:23:37 nicm Exp $ */ +/* $Id: key-bindings.c,v 1.28 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -77,41 +77,40 @@ key_bindings_init(void) struct { int key; const struct cmd_entry *entry; - void (*fn)(void **, int); } table[] = { - { '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 }, - { 'w', &cmd_list_windows_entry, NULL }, - { '?', &cmd_list_keys_entry, NULL }, - { '/', &cmd_list_keys_entry, NULL }, - { 'C', &cmd_new_window_entry, NULL }, - { 'c', &cmd_new_window_entry, NULL }, - { 'N', &cmd_next_window_entry, NULL }, - { 'n', &cmd_next_window_entry, NULL }, - { 'P', &cmd_previous_window_entry, NULL }, - { 'p', &cmd_previous_window_entry, NULL }, - { 'L', &cmd_last_window_entry, NULL }, - { 'l', &cmd_last_window_entry, NULL }, - { '0', &cmd_select_window_entry, cmd_select_window_default }, - { '1', &cmd_select_window_entry, cmd_select_window_default }, - { '2', &cmd_select_window_entry, cmd_select_window_default }, - { '3', &cmd_select_window_entry, cmd_select_window_default }, - { '4', &cmd_select_window_entry, cmd_select_window_default }, - { '5', &cmd_select_window_entry, cmd_select_window_default }, - { '6', &cmd_select_window_entry, cmd_select_window_default }, - { '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_client_entry, NULL }, - { 'r', &cmd_refresh_client_entry, NULL }, - { '&', &cmd_kill_window_entry, NULL }, - { '=', &cmd_scroll_mode_entry, NULL }, - { '[', &cmd_copy_mode_entry, NULL }, - { ']', &cmd_paste_buffer_entry, NULL }, - { META, &cmd_send_prefix_entry, NULL }, + { 'D', &cmd_detach_client_entry }, + { 'd', &cmd_detach_client_entry }, + { 'S', &cmd_list_sessions_entry }, + { 's', &cmd_list_sessions_entry }, + { 'W', &cmd_list_windows_entry }, + { 'w', &cmd_list_windows_entry }, + { '?', &cmd_list_keys_entry }, + { '/', &cmd_list_keys_entry }, + { 'C', &cmd_new_window_entry }, + { 'c', &cmd_new_window_entry }, + { 'N', &cmd_next_window_entry }, + { 'n', &cmd_next_window_entry }, + { 'P', &cmd_previous_window_entry }, + { 'p', &cmd_previous_window_entry }, + { 'L', &cmd_last_window_entry }, + { 'l', &cmd_last_window_entry }, + { '0', &cmd_select_window_entry }, + { '1', &cmd_select_window_entry }, + { '2', &cmd_select_window_entry }, + { '3', &cmd_select_window_entry }, + { '4', &cmd_select_window_entry }, + { '5', &cmd_select_window_entry }, + { '6', &cmd_select_window_entry }, + { '7', &cmd_select_window_entry }, + { '8', &cmd_select_window_entry }, + { '9', &cmd_select_window_entry }, + { 'R', &cmd_refresh_client_entry }, + { 'r', &cmd_refresh_client_entry }, + { '&', &cmd_kill_window_entry }, + { '=', &cmd_scroll_mode_entry }, + { '[', &cmd_copy_mode_entry }, + { ']', &cmd_paste_buffer_entry }, + { META, &cmd_send_prefix_entry }, }; u_int i; struct cmd *cmd; @@ -122,8 +121,8 @@ key_bindings_init(void) cmd = xmalloc(sizeof *cmd); cmd->entry = table[i].entry; cmd->data = NULL; - if (table[i].fn != NULL) - table[i].fn(&cmd->data, table[i].key); + if (cmd->entry->init != NULL) + cmd->entry->init(&cmd->data, table[i].key); key_bindings_add(table[i].key, cmd); } } diff --git a/tmux.1 b/tmux.1 index 4da792d7..89d253b5 100644 --- a/tmux.1 +++ b/tmux.1 @@ -1,4 +1,4 @@ -.\" $Id: tmux.1,v 1.25 2008-06-02 21:36:51 nicm Exp $ +.\" $Id: tmux.1,v 1.26 2008-06-03 05:35:51 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -25,8 +25,7 @@ .Bk -words .Op Fl vV .Op Fl S Ar socket-path -.Ar command -.Op Ar arguments +.Op Ar command Op Ar arguments .Ek .Sh DESCRIPTION .Nm @@ -71,6 +70,9 @@ is the pid of the server or client process. This specifies one of a set of commands used to control .Nm , and described in the following sections. +If no command and arguments is specified, the +.Ic new-session +command is assumed. .Pp .El .Sh QUICK START @@ -278,6 +280,11 @@ Detach the current client if bound to a key, or the specified client with .D1 (alias: Ic has ) Report an error and exit with 1 if the specified session does not exist. If it does exist, exit with 0. +.It Xo Ic kill-server +.Xc +Kill the +.Nm +server and clients and destroy all sessions. .It Xo Ic kill-session .Op Fl s Ar session-name .Xc @@ -506,6 +513,11 @@ created) to The default is .Dq exec $SHELL . .El +.It Xo Ic start-server +.Xc +Start the +.Nm +server, if not already running, without creating any sessions. .It Xo Ic swap-window .Op Fl i Ar index .Op Fl s Ar session-name diff --git a/tmux.c b/tmux.c index ca255b0c..67ff2a58 100644 --- a/tmux.c +++ b/tmux.c @@ -1,4 +1,4 @@ -/* $Id: tmux.c,v 1.48 2008-06-02 21:08:36 nicm Exp $ */ +/* $Id: tmux.c,v 1.49 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -59,7 +59,7 @@ __dead void usage(void) { fprintf(stderr, - "usage: %s [-v] [-f file] [-S socket-path] command [flags]", + "usage: %s [-v] [-f file] [-S socket-path] [command [flags]]", __progname); exit(1); } @@ -197,8 +197,6 @@ main(int argc, char **argv) } argc -= optind; argv += optind; - if (argc == 0) - usage(); log_open(stderr, LOG_USER, debug_level); siginit(); @@ -264,7 +262,11 @@ main(int argc, char **argv) } xasprintf(&default_command, "exec %s", shell); - if ((cmd = cmd_parse(argc, argv, &cause)) == NULL) { + if (argc == 0) { + cmd = xmalloc(sizeof *cmd); + cmd->entry = &cmd_new_session_entry; + cmd->entry->init(&cmd->data, 0); + } else if ((cmd = cmd_parse(argc, argv, &cause)) == NULL) { log_warnx("%s", cause); exit(1); } diff --git a/tmux.h b/tmux.h index b56f44cf..d51f5d5c 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.121 2008-06-03 05:10:38 nicm Exp $ */ +/* $Id: tmux.h,v 1.122 2008-06-03 05:35:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -654,6 +654,7 @@ struct cmd_entry { void (*send)(void *, struct buffer *); void (*recv)(void **, struct buffer *); void (*free)(void *); + void (*init)(void **, int); }; /* Key binding. */ @@ -764,7 +765,6 @@ extern const struct cmd_entry cmd_swap_window_entry; extern const struct cmd_entry cmd_switch_client_entry; extern const struct cmd_entry cmd_unbind_key_entry; extern const struct cmd_entry cmd_unlink_window_entry; -void cmd_select_window_default(void **, int); /* cmd-generic.c */ #define CMD_CLIENTONLY_USAGE "[-c client-tty]"