diff options
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | cmd-generic.c | 17 | ||||
-rw-r--r-- | cmd-select-window.c | 128 | ||||
-rw-r--r-- | tmux.1 | 4 | ||||
-rw-r--r-- | tmux.h | 18 |
5 files changed, 35 insertions, 136 deletions
@@ -1,5 +1,7 @@ 04 June 2008 +* Brought select-window command into line with everything else; it now uses + -i for the window index. * Strings to display on the left and right of the status bar may now be set with the status-left and status-right options. These are passed through strftime(3) before being displayed. The status bar is automatically updated @@ -391,4 +393,4 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.104 2008-06-04 05:40:35 nicm Exp $ +$Id: CHANGES,v 1.105 2008-06-04 16:11:52 nicm Exp $ diff --git a/cmd-generic.c b/cmd-generic.c index 7152fd7c..a5dad562 100644 --- a/cmd-generic.c +++ b/cmd-generic.c @@ -1,4 +1,4 @@ -/* $Id: cmd-generic.c,v 1.4 2008-06-03 16:55:09 nicm Exp $ */ +/* $Id: cmd-generic.c,v 1.5 2008-06-04 16:11:52 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -23,21 +23,6 @@ #include "tmux.h" -struct cmd_clientonly_data { - char *cname; -}; - -struct cmd_sessiononly_data { - char *cname; - char *sname; -}; - -struct cmd_windowonly_data { - char *cname; - char *sname; - int idx; -}; - int cmd_clientonly_parse( struct cmd *self, void **ptr, int argc, char **argv, char **cause) diff --git a/cmd-select-window.c b/cmd-select-window.c index d1bf235f..703bed05 100644 --- a/cmd-select-window.c +++ b/cmd-select-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-select-window.c,v 1.15 2008-06-03 16:55:09 nicm Exp $ */ +/* $Id: cmd-select-window.c,v 1.16 2008-06-04 16:11:52 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -27,35 +27,25 @@ * Select window by index. */ -int cmd_select_window_parse(struct cmd *, void **, int, char **, char **); -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 *cname; - char *sname; - int idx; -}; +void cmd_select_window_exec(void *, struct cmd_ctx *); const struct cmd_entry cmd_select_window_entry = { "select-window", "selectw", - "[-c client-tty|-s session-name] index", + CMD_WINDOWONLY_USAGE, 0, - cmd_select_window_parse, + cmd_windowonly_parse, cmd_select_window_exec, - cmd_select_window_send, - cmd_select_window_recv, - cmd_select_window_free, + cmd_windowonly_send, + cmd_windowonly_recv, + cmd_windowonly_free, cmd_select_window_init }; void cmd_select_window_init(void **ptr, int arg) { - struct cmd_select_window_data *data; + struct cmd_windowonly_data *data; *ptr = data = xmalloc(sizeof *data); data->cname = NULL; @@ -63,112 +53,18 @@ cmd_select_window_init(void **ptr, int arg) data->idx = arg - '0'; } -int -cmd_select_window_parse( - struct cmd *self, void **ptr, int argc, char **argv, char **cause) -{ - struct cmd_select_window_data *data; - const char *errstr; - int opt; - - *ptr = data = xmalloc(sizeof *data); - data->sname = NULL; - - while ((opt = getopt(argc, argv, "c:s:")) != EOF) { - switch (opt) { - case 'c': - if (data->sname != NULL) - goto usage; - if (data->cname == NULL) - data->cname = xstrdup(optarg); - break; - case 's': - if (data->cname != NULL) - goto usage; - if (data->sname == NULL) - data->sname = xstrdup(optarg); - break; - default: - goto usage; - } - } - argc -= optind; - argv += optind; - if (argc != 1) - goto usage; - - data->idx = strtonum(argv[0], 0, INT_MAX, &errstr); - if (errstr != NULL) { - xasprintf(cause, "index %s", errstr); - goto error; - } - - return (0); - -usage: - xasprintf(cause, "usage: %s %s", self->entry->name, self->entry->usage); - -error: - cmd_select_window_free(data); - return (-1); -} - void cmd_select_window_exec(void *ptr, struct cmd_ctx *ctx) { - struct cmd_select_window_data *data = ptr; - struct session *s; - - if (data == NULL) - return; + struct winlink *wl; + struct session *s; - if ((s = cmd_find_session(ctx, data->cname, data->sname)) == NULL) + if ((wl = cmd_windowonly_get(ptr, ctx, &s)) == NULL) return; - switch (session_select(s, data->idx)) { - case 0: + if (session_select(s, wl->idx) == 0) server_redraw_session(s); - break; - case 1: - break; - default: - ctx->error(ctx, "no window %d", data->idx); - break; - } if (ctx->cmdclient != NULL) server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); } - -void -cmd_select_window_send(void *ptr, struct buffer *b) -{ - struct cmd_select_window_data *data = ptr; - - buffer_write(b, data, sizeof *data); - cmd_send_string(b, data->cname); - cmd_send_string(b, data->sname); -} - -void -cmd_select_window_recv(void **ptr, struct buffer *b) -{ - struct cmd_select_window_data *data; - - *ptr = data = xmalloc(sizeof *data); - buffer_read(b, data, sizeof *data); - data->cname = cmd_recv_string(b); - data->sname = cmd_recv_string(b); -} - -void -cmd_select_window_free(void *ptr) -{ - struct cmd_select_window_data *data = ptr; - - if (data->cname != NULL) - xfree(data->cname); - if (data->sname != NULL) - xfree(data->sname); - xfree(data); -} @@ -1,4 +1,4 @@ -.\" $Id: tmux.1,v 1.26 2008-06-03 05:35:51 nicm Exp $ +.\" $Id: tmux.1,v 1.27 2008-06-04 16:11:53 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -440,7 +440,7 @@ if specifed, to Enter scroll mode. .It Xo Ic select-window .Op Fl s Ar session-name -.Ar index +.Op Fl i Ar index .Xc .D1 (alias: Ic selectw ) Select the window at @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.126 2008-06-04 05:40:35 nicm Exp $ */ +/* $Id: tmux.h,v 1.127 2008-06-04 16:11:53 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -681,6 +681,22 @@ struct cmd_entry { void (*init)(void **, int); }; +/* Generic command data. */ +struct cmd_clientonly_data { + char *cname; +}; + +struct cmd_sessiononly_data { + char *cname; + char *sname; +}; + +struct cmd_windowonly_data { + char *cname; + char *sname; + int idx; +}; + /* Key binding. */ struct binding { int key; |