If no command is specified, assume new-session.

This commit is contained in:
Nicholas Marriott 2008-06-03 05:35:51 +00:00
parent eaee4dc800
commit f91e7bfd38
37 changed files with 189 additions and 134 deletions

View File

@ -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 $

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -37,6 +37,7 @@ const struct cmd_entry cmd_kill_server_entry = {
cmd_kill_server_exec,
NULL,
NULL,
NULL,
NULL
};

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -37,6 +37,7 @@ const struct cmd_entry cmd_list_clients_entry = {
cmd_list_clients_exec,
NULL,
NULL,
NULL,
NULL
};

View File

@ -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 <nicm@users.sourceforge.net>
@ -34,6 +34,7 @@ const struct cmd_entry cmd_list_keys_entry = {
cmd_list_keys_exec,
NULL,
NULL,
NULL,
NULL
};

View File

@ -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 <nicm@users.sourceforge.net>
@ -18,6 +18,7 @@
#include <sys/types.h>
#include <string.h>
#include <time.h>
#include "tmux.h"
@ -35,6 +36,7 @@ const struct cmd_entry cmd_list_sessions_entry = {
cmd_list_sessions_exec,
NULL,
NULL,
NULL,
NULL
};

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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;

View File

@ -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 <nicm@users.sourceforge.net>
@ -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;

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -34,6 +34,7 @@ const struct cmd_entry cmd_start_server_entry = {
cmd_start_server_exec,
NULL,
NULL,
NULL,
NULL
};

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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

View File

@ -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 <nicm@users.sourceforge.net>
@ -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);
}
}

18
tmux.1
View File

@ -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 <nicm@users.sourceforge.net>
.\"
@ -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

12
tmux.c
View File

@ -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 <nicm@users.sourceforge.net>
@ -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);
}

4
tmux.h
View File

@ -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 <nicm@users.sourceforge.net>
@ -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]"