From a15f8fc4a66420615d237313c6a01fcf532c52a2 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 18 Jan 2009 14:40:48 +0000 Subject: Support command sequences separated by " ; ". Also clean up command printing. --- CHANGES | 15 +++++- GNUmakefile | 4 +- Makefile | 4 +- TODO | 6 ++- cfg.c | 22 ++++---- cmd-bind-key.c | 38 +++++++------- cmd-command-prompt.c | 14 ++--- cmd-generic.c | 52 +++++++++++------- cmd-list-keys.c | 14 +++-- cmd-list.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++ cmd-new-session.c | 15 +++--- cmd-new-window.c | 15 +++--- cmd-send-keys.c | 11 ++-- cmd-set-password.c | 9 ++-- cmd-set-window-option.c | 4 +- cmd-source-file.c | 11 ++-- cmd-split-window.c | 13 ++--- cmd-string.c | 11 ++-- cmd-switch-client.c | 13 ++--- cmd.c | 11 +++- key-bindings.c | 22 +++++--- server.c | 17 ++++-- tmux.h | 35 +++++++++---- 23 files changed, 350 insertions(+), 143 deletions(-) create mode 100644 cmd-list.c diff --git a/CHANGES b/CHANGES index 89ee59c2..9f6ccf49 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,18 @@ 18 January 2009 +* Cleaned up command printing code, also enclose arguments with spaces in "s. +* Added command sequences. These are entered by separating each argument by a ; + argument (spaces on both sides), for example: + + lsk ; lsc + + To use a literal ; as the argument prefix it with \, for example: + + bind x lsk \; lsc + + Commands are executed from left to right and, importantly, an error does NOT + stop execution. Also note that command sequences do not support repeat-time + repetition unless all commands making up the sequence support it. * suspend-client command to suspend a client. Don't try to background it though... * Mark attached sessions in sessions lists. Suggested by Simon Kuhnle. @@ -938,7 +951,7 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.216 2009-01-18 12:13:21 nicm Exp $ +$Id: CHANGES,v 1.217 2009-01-18 14:40:48 nicm Exp $ LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms diff --git a/GNUmakefile b/GNUmakefile index fbfb61ab..cde1deb3 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,4 +1,4 @@ -# $Id: GNUmakefile,v 1.59 2009-01-18 12:09:42 nicm Exp $ +# $Id: GNUmakefile,v 1.60 2009-01-18 14:40:48 nicm Exp $ .PHONY: clean @@ -17,7 +17,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \ grid.c grid-view.c \ window.c session.c log.c client.c client-msg.c client-fn.c cfg.c \ key-string.c key-bindings.c resize.c arg.c mode-key.c \ - cmd.c cmd-generic.c cmd-string.c \ + cmd.c cmd-generic.c cmd-string.c cmd-list.c \ cmd-detach-client.c cmd-list-sessions.c cmd-new-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 \ diff --git a/Makefile b/Makefile index 67672dd2..c7c7d8b3 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.98 2009-01-18 12:09:42 nicm Exp $ +# $Id: Makefile,v 1.99 2009-01-18 14:40:48 nicm Exp $ .SUFFIXES: .c .o .y .h .PHONY: clean update-index.html upload-index.html @@ -21,7 +21,7 @@ SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \ grid.c grid-view.c \ window.c session.c log.c client.c client-msg.c client-fn.c cfg.c \ key-string.c key-bindings.c resize.c arg.c mode-key.c \ - cmd.c cmd-generic.c cmd-string.c \ + cmd.c cmd-generic.c cmd-string.c cmd-list.c \ cmd-detach-client.c cmd-list-sessions.c cmd-new-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 \ diff --git a/TODO b/TODO index f57ccafc..05cf057f 100644 --- a/TODO +++ b/TODO @@ -70,10 +70,12 @@ - command: load-buffer -b number filename - command: copy-buffer -s src-session -t dst-session -a src-index -b dst-index (copy from other session) -- function groups, bind-key ^W { select-window 0; send-key ^W } etc *** - neww should support -k -- document suspend-client - flag to scroll-mode/copy-mode to automatically scroll up a page - would be nice if tmux could be the shell - key to switch to copy mode from scroll mode - clone session command +- document suspend-client +- document command sequences +- make command sequences more usable: don't require space around ;, handle + errors better diff --git a/cfg.c b/cfg.c index 44f516b7..7e38a0a6 100644 --- a/cfg.c +++ b/cfg.c @@ -1,4 +1,4 @@ -/* $Id: cfg.c,v 1.13 2008-07-25 17:20:40 nicm Exp $ */ +/* $Id: cfg.c,v 1.14 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -53,12 +53,12 @@ cfg_error(unused struct cmd_ctx *ctx, const char *fmt, ...) int load_cfg(const char *path, char **cause) { - FILE *f; - u_int n; - char *buf, *line, *ptr; - size_t len; - struct cmd *cmd; - struct cmd_ctx ctx; + FILE *f; + u_int n; + char *buf, *line, *ptr; + size_t len; + struct cmd_list *cmdlist; + struct cmd_ctx ctx; if ((f = fopen(path, "rb")) == NULL) { xasprintf(cause, "%s: %s", path, strerror(errno)); @@ -78,12 +78,12 @@ load_cfg(const char *path, char **cause) } n++; - if (cmd_string_parse(buf, &cmd, cause) != 0) { + if (cmd_string_parse(buf, &cmdlist, cause) != 0) { if (*cause == NULL) continue; goto error; } - if (cmd == NULL) + if (cmdlist == NULL) continue; cfg_cause = NULL; @@ -98,8 +98,8 @@ load_cfg(const char *path, char **cause) ctx.cmdclient = NULL; cfg_cause = NULL; - cmd_exec(cmd, &ctx); - cmd_free(cmd); + cmd_list_exec(cmdlist, &ctx); + cmd_list_free(cmdlist); if (cfg_cause != NULL) { *cause = cfg_cause; goto error; diff --git a/cmd-bind-key.c b/cmd-bind-key.c index 11d63c04..ba00f244 100644 --- a/cmd-bind-key.c +++ b/cmd-bind-key.c @@ -1,4 +1,4 @@ -/* $Id: cmd-bind-key.c,v 1.17 2008-12-10 20:25:41 nicm Exp $ */ +/* $Id: cmd-bind-key.c,v 1.18 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -29,11 +29,11 @@ void cmd_bind_key_exec(struct cmd *, struct cmd_ctx *); void cmd_bind_key_send(struct cmd *, struct buffer *); void cmd_bind_key_recv(struct cmd *, struct buffer *); void cmd_bind_key_free(struct cmd *); -void cmd_bind_key_print(struct cmd *, char *, size_t); +size_t cmd_bind_key_print(struct cmd *, char *, size_t); struct cmd_bind_key_data { int key; - struct cmd *cmd; + struct cmd_list *cmdlist; }; const struct cmd_entry cmd_bind_key_entry = { @@ -56,7 +56,7 @@ cmd_bind_key_parse(struct cmd *self, int argc, char **argv, char **cause) int opt; self->data = data = xmalloc(sizeof *data); - data->cmd = NULL; + data->cmdlist = NULL; while ((opt = getopt(argc, argv, "")) != -1) { switch (opt) { @@ -76,7 +76,7 @@ cmd_bind_key_parse(struct cmd *self, int argc, char **argv, char **cause) argc--; argv++; - if ((data->cmd = cmd_parse(argc, argv, cause)) == NULL) + if ((data->cmdlist = cmd_list_parse(argc, argv, cause)) == NULL) goto error; return (0); @@ -97,8 +97,8 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_ctx *ctx) if (data == NULL) return; - key_bindings_add(data->key, data->cmd); - data->cmd = NULL; /* avoid free */ + key_bindings_add(data->key, data->cmdlist); + data->cmdlist = NULL; /* avoid free */ if (ctx->cmdclient != NULL) server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); @@ -110,7 +110,7 @@ cmd_bind_key_send(struct cmd *self, struct buffer *b) struct cmd_bind_key_data *data = self->data; buffer_write(b, data, sizeof *data); - cmd_send(data->cmd, b); + cmd_list_send(data->cmdlist, b); } void @@ -120,7 +120,7 @@ cmd_bind_key_recv(struct cmd *self, struct buffer *b) self->data = data = xmalloc(sizeof *data); buffer_read(b, data, sizeof *data); - data->cmd = cmd_recv(b); + data->cmdlist = cmd_list_recv(b); } void @@ -128,26 +128,26 @@ cmd_bind_key_free(struct cmd *self) { struct cmd_bind_key_data *data = self->data; - if (data->cmd != NULL) - cmd_free(data->cmd); + if (data->cmdlist != NULL) + cmd_list_free(data->cmdlist); xfree(data); } -void +size_t cmd_bind_key_print(struct cmd *self, char *buf, size_t len) { struct cmd_bind_key_data *data = self->data; size_t off = 0; + const char *skey; off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) - return; + return (off); if (off < len) { - off += xsnprintf(buf + off, - len - off, " %s", key_string_lookup_key(data->key)); - } - if (off < len && data->cmd != NULL) { - off += xsnprintf(buf + off, len - off, " "); - data->cmd->entry->print(data->cmd, buf + off, len - off); + skey = key_string_lookup_key(data->key); + off += xsnprintf(buf + off, len - off, " %s ", skey); } + if (off < len) + off += cmd_list_print(data->cmdlist, buf + off, len - off); + return (off); } diff --git a/cmd-command-prompt.c b/cmd-command-prompt.c index 72c13fd0..cdcbd424 100644 --- a/cmd-command-prompt.c +++ b/cmd-command-prompt.c @@ -1,4 +1,4 @@ -/* $Id: cmd-command-prompt.c,v 1.9 2009-01-14 22:16:56 nicm Exp $ */ +/* $Id: cmd-command-prompt.c,v 1.10 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -60,7 +60,7 @@ cmd_command_prompt_init(struct cmd *self, int key) switch (key) { case ',': - data->arg = xstrdup("rename-window \"%%\""); + data->arg = xstrdup("rename-window '%%'"); break; } } @@ -102,7 +102,7 @@ cmd_command_prompt_callback(void *data, const char *s) { struct cmd_command_prompt_data *cdata = data; struct client *c = cdata->c; - struct cmd *cmd; + struct cmd_list *cmdlist; struct cmd_ctx ctx; char *cause, *ptr, *buf, ch; size_t len, slen; @@ -139,17 +139,17 @@ cmd_command_prompt_callback(void *data, const char *s) } xfree(cdata); - if (cmd_string_parse(s, &cmd, &cause) != 0) { + if (cmd_string_parse(s, &cmdlist, &cause) != 0) { if (cause == NULL) return (0); *cause = toupper((u_char) *cause); server_set_client_message(c, cause); xfree(cause); - cmd = NULL; + cmdlist = NULL; } if (buf != NULL) xfree(buf); - if (cmd == NULL) + if (cmdlist == NULL) return (0); ctx.msgdata = NULL; @@ -162,7 +162,7 @@ cmd_command_prompt_callback(void *data, const char *s) ctx.cmdclient = NULL; - cmd_exec(cmd, &ctx); + cmd_list_exec(cmdlist, &ctx); if (c->prompt_callback != (void *) &cmd_command_prompt_callback) return (1); diff --git a/cmd-generic.c b/cmd-generic.c index b0f41ea6..30fed7e1 100644 --- a/cmd-generic.c +++ b/cmd-generic.c @@ -1,4 +1,4 @@ -/* $Id: cmd-generic.c,v 1.21 2009-01-14 22:16:56 nicm Exp $ */ +/* $Id: cmd-generic.c,v 1.22 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -19,6 +19,7 @@ #include #include +#include #include "tmux.h" @@ -28,6 +29,14 @@ int cmd_do_flags(int, int, int *); size_t cmd_print_flags(char *, size_t, size_t, int); int cmd_fill_argument(int, char **, int, char **); +size_t +cmd_prarg(char *buf, size_t len, const char *prefix, char *arg) +{ + if (strchr(arg, ' ' ) != NULL) + return (xsnprintf(buf, len, "%s\"%s\"", prefix, arg)); + return (xsnprintf(buf, len, "%s%s", prefix, arg)); +} + int cmd_do_flags(int opt, int iflags, int *oflags) { @@ -194,7 +203,7 @@ cmd_target_free(struct cmd *self) xfree(data); } -void +size_t cmd_target_print(struct cmd *self, char *buf, size_t len) { struct cmd_target_data *data = self->data; @@ -202,12 +211,13 @@ cmd_target_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) - return; + return (off); off += cmd_print_flags(buf, len, off, data->flags); if (off < len && data->target != NULL) - off += xsnprintf(buf + off, len - off, " -t %s", data->target); + off += cmd_prarg(buf + off, len - off, " -t ", data->target); if (off < len && data->arg != NULL) - off += xsnprintf(buf + off, len - off, " %s", data->arg); + off += cmd_prarg(buf + off, len - off, " ", data->arg); + return (off); } void @@ -302,7 +312,7 @@ cmd_srcdst_free(struct cmd *self) xfree(data); } -void +size_t cmd_srcdst_print(struct cmd *self, char *buf, size_t len) { struct cmd_srcdst_data *data = self->data; @@ -310,14 +320,15 @@ cmd_srcdst_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) - return; + return (off); off += cmd_print_flags(buf, len, off, data->flags); if (off < len && data->src != NULL) off += xsnprintf(buf + off, len - off, " -s %s", data->src); if (off < len && data->dst != NULL) off += xsnprintf(buf + off, len - off, " -t %s", data->dst); if (off < len && data->arg != NULL) - off += xsnprintf(buf + off, len - off, " %s", data->arg); + off += cmd_prarg(buf + off, len - off, " ", data->arg); + return (off); } void @@ -416,7 +427,7 @@ cmd_buffer_free(struct cmd *self) xfree(data); } -void +size_t cmd_buffer_print(struct cmd *self, char *buf, size_t len) { struct cmd_buffer_data *data = self->data; @@ -424,14 +435,15 @@ cmd_buffer_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) - return; + return (off); off += cmd_print_flags(buf, len, off, data->flags); if (off < len && data->buffer != -1) off += xsnprintf(buf + off, len - off, " -b %d", data->buffer); if (off < len && data->target != NULL) - off += xsnprintf(buf + off, len - off, " -t %s", data->target); + off += cmd_prarg(buf + off, len - off, " -t ", data->target); if (off < len && data->arg != NULL) - off += xsnprintf(buf + off, len - off, " %s", data->arg); + off += cmd_prarg(buf + off, len - off, " ", data->arg); + return (off); } void @@ -528,7 +540,7 @@ cmd_option_free(struct cmd *self) xfree(data); } -void +size_t cmd_option_print(struct cmd *self, char *buf, size_t len) { struct cmd_option_data *data = self->data; @@ -536,14 +548,15 @@ cmd_option_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) - return; + return (off); off += cmd_print_flags(buf, len, off, data->flags); if (off < len && data->target != NULL) - off += xsnprintf(buf + off, len - off, " -t %s", data->target); + off += cmd_prarg(buf + off, len - off, " -t ", data->target); if (off < len && data->option != NULL) off += xsnprintf(buf + off, len - off, " %s", data->option); if (off < len && data->value != NULL) off += xsnprintf(buf + off, len - off, " %s", data->value); + return (off); } void @@ -643,7 +656,7 @@ cmd_pane_free(struct cmd *self) xfree(data); } -void +size_t cmd_pane_print(struct cmd *self, char *buf, size_t len) { struct cmd_pane_data *data = self->data; @@ -651,10 +664,11 @@ cmd_pane_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) - return; + return (off); off += cmd_print_flags(buf, len, off, data->flags); if (off < len && data->target != NULL) - off += xsnprintf(buf + off, len - off, " -t %s", data->target); + off += cmd_prarg(buf + off, len - off, " -t ", data->target); if (off < len && data->arg != NULL) - off += xsnprintf(buf + off, len - off, " %s", data->arg); + off += cmd_prarg(buf + off, len - off, " ", data->arg); + return (off); } diff --git a/cmd-list-keys.c b/cmd-list-keys.c index 299681b9..faa29916 100644 --- a/cmd-list-keys.c +++ b/cmd-list-keys.c @@ -1,4 +1,4 @@ -/* $Id: cmd-list-keys.c,v 1.11 2009-01-06 14:10:32 nicm Exp $ */ +/* $Id: cmd-list-keys.c,v 1.12 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -44,17 +44,15 @@ cmd_list_keys_exec(unused struct cmd *self, struct cmd_ctx *ctx) { struct key_binding *bd; const char *key; - char s[BUFSIZ]; + char tmp[BUFSIZ]; SPLAY_FOREACH(bd, key_bindings, &key_bindings) { if ((key = key_string_lookup_key(bd->key)) == NULL) continue; - if (bd->cmd->entry->print == NULL) { - ctx->print(ctx, "%11s: %s", key, bd->cmd->entry->name); - continue; - } - bd->cmd->entry->print(bd->cmd, s, sizeof s); - ctx->print(ctx, "%11s: %s", key, s); + + *tmp = '\0'; + cmd_list_print(bd->cmdlist, tmp, sizeof tmp); + ctx->print(ctx, "%11s: %s", key, tmp); } if (ctx->cmdclient != NULL) diff --git a/cmd-list.c b/cmd-list.c new file mode 100644 index 00000000..8edaff56 --- /dev/null +++ b/cmd-list.c @@ -0,0 +1,137 @@ +/* $Id: cmd-list.c,v 1.1 2009-01-18 14:40:48 nicm Exp $ */ + +/* + * Copyright (c) 2009 Nicholas Marriott + * + * 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 + +#include + +#include "tmux.h" + +struct cmd_list * +cmd_list_parse(int argc, char **argv, char **cause) +{ + struct cmd_list *cmdlist; + struct cmd *cmd; + int i, lastsplit; + + cmdlist = xmalloc(sizeof *cmdlist); + TAILQ_INIT(cmdlist); + + lastsplit = 0; + for (i = 0; i < argc; i++) { + if (strcmp(argv[i], "\\;") == 0) { + argv[i][0] = ';'; + argv[i][1] = '\0'; + } else if (strcmp(argv[i], ";") == 0) { + cmd = cmd_parse(i - lastsplit, argv + lastsplit, cause); + if (cmd == NULL) + goto bad; + TAILQ_INSERT_TAIL(cmdlist, cmd, qentry); + lastsplit = i + 1; + } + } + + cmd = cmd_parse(argc - lastsplit, argv + lastsplit, cause); + if (cmd == NULL) { + cmd_list_free(cmdlist); + return (NULL); + } + TAILQ_INSERT_TAIL(cmdlist, cmd, qentry); + + return (cmdlist); + +bad: + cmd_list_free(cmdlist); + return (NULL); +} + +void +cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx) +{ + struct cmd *cmd; + + TAILQ_FOREACH(cmd, cmdlist, qentry) + cmd_exec(cmd, ctx); +} + +void +cmd_list_send(struct cmd_list *cmdlist, struct buffer *b) +{ + struct cmd *cmd; + u_int n; + + n = 0; + TAILQ_FOREACH(cmd, cmdlist, qentry) + n++; + + buffer_write(b, &n, sizeof n); + TAILQ_FOREACH(cmd, cmdlist, qentry) + cmd_send(cmd, b); +} + +struct cmd_list * +cmd_list_recv(struct buffer *b) +{ + struct cmd_list *cmdlist; + struct cmd *cmd; + u_int n; + + buffer_read(b, &n, sizeof n); + + cmdlist = xmalloc(sizeof *cmdlist); + TAILQ_INIT(cmdlist); + + while (n-- > 0) { + cmd = cmd_recv(b); + TAILQ_INSERT_TAIL(cmdlist, cmd, qentry); + } + + return (cmdlist); +} + +void +cmd_list_free(struct cmd_list *cmdlist) +{ + struct cmd *cmd; + + while (!TAILQ_EMPTY(cmdlist)) { + cmd = TAILQ_FIRST(cmdlist); + TAILQ_REMOVE(cmdlist, cmd, qentry); + cmd_free(cmd); + } + xfree(cmdlist); +} + +size_t +cmd_list_print(struct cmd_list *cmdlist, char *buf, size_t len) +{ + struct cmd *cmd; + size_t off; + + off = 0; + TAILQ_FOREACH(cmd, cmdlist, qentry) { + if (off >= len) + break; + off += cmd_print(cmd, buf + off, len - off); + if (off >= len) + break; + if (TAILQ_NEXT(cmd, qentry) != NULL) + off += xsnprintf(buf + off, len - off, " ; "); + } + return (off); +} diff --git a/cmd-new-session.c b/cmd-new-session.c index fbb92894..e8315d16 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-new-session.c,v 1.34 2009-01-11 00:48:42 nicm Exp $ */ +/* $Id: cmd-new-session.c,v 1.35 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -30,7 +30,7 @@ void cmd_new_session_send(struct cmd *, struct buffer *); void cmd_new_session_recv(struct cmd *, struct buffer *); void cmd_new_session_free(struct cmd *); void cmd_new_session_init(struct cmd *, int); -void cmd_new_session_print(struct cmd *, char *, size_t); +size_t cmd_new_session_print(struct cmd *, char *, size_t); struct cmd_new_session_data { char *newname; @@ -218,7 +218,7 @@ cmd_new_session_free(struct cmd *self) xfree(data); } -void +size_t cmd_new_session_print(struct cmd *self, char *buf, size_t len) { struct cmd_new_session_data *data = self->data; @@ -226,13 +226,14 @@ cmd_new_session_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) - return; + return (off); if (off < len && data->flag_detached) off += xsnprintf(buf + off, len - off, " -d"); if (off < len && data->newname != NULL) - off += xsnprintf(buf + off, len - off, " -s %s", data->newname); + off += cmd_prarg(buf + off, len - off, " -s ", data->newname); if (off < len && data->winname != NULL) - off += xsnprintf(buf + off, len - off, " -n %s", data->winname); + off += cmd_prarg(buf + off, len - off, " -n ", data->winname); if (off < len && data->cmd != NULL) - off += xsnprintf(buf + off, len - off, " %s", data->cmd); + off += cmd_prarg(buf + off, len - off, " ", data->cmd); + return (off); } diff --git a/cmd-new-window.c b/cmd-new-window.c index 2dad77e8..25a1fb21 100644 --- a/cmd-new-window.c +++ b/cmd-new-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-new-window.c,v 1.27 2009-01-10 19:37:35 nicm Exp $ */ +/* $Id: cmd-new-window.c,v 1.28 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -32,7 +32,7 @@ void cmd_new_window_send(struct cmd *, struct buffer *); void cmd_new_window_recv(struct cmd *, struct buffer *); void cmd_new_window_free(struct cmd *); void cmd_new_window_init(struct cmd *, int); -void cmd_new_window_print(struct cmd *, char *, size_t); +size_t cmd_new_window_print(struct cmd *, char *, size_t); struct cmd_new_window_data { char *target; @@ -194,7 +194,7 @@ cmd_new_window_free(struct cmd *self) xfree(data); } -void +size_t cmd_new_window_print(struct cmd *self, char *buf, size_t len) { struct cmd_new_window_data *data = self->data; @@ -202,13 +202,14 @@ cmd_new_window_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) - return; + return (off); if (off < len && data->flag_detached) off += xsnprintf(buf + off, len - off, " -d"); if (off < len && data->target != NULL) - off += xsnprintf(buf + off, len - off, " -t %s", data->target); + off += cmd_prarg(buf + off, len - off, " -t ", data->target); if (off < len && data->name != NULL) - off += xsnprintf(buf + off, len - off, " -n %s", data->name); + off += cmd_prarg(buf + off, len - off, " -n ", data->name); if (off < len && data->cmd != NULL) - off += xsnprintf(buf + off, len - off, " %s", data->cmd); + off += cmd_prarg(buf + off, len - off, " ", data->cmd); + return (off); } diff --git a/cmd-send-keys.c b/cmd-send-keys.c index afded43c..95e73f02 100644 --- a/cmd-send-keys.c +++ b/cmd-send-keys.c @@ -1,4 +1,4 @@ -/* $Id: cmd-send-keys.c,v 1.16 2009-01-11 23:31:46 nicm Exp $ */ +/* $Id: cmd-send-keys.c,v 1.17 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -31,7 +31,7 @@ void cmd_send_keys_exec(struct cmd *, struct cmd_ctx *); void cmd_send_keys_send(struct cmd *, struct buffer *); void cmd_send_keys_recv(struct cmd *, struct buffer *); void cmd_send_keys_free(struct cmd *); -void cmd_send_keys_print(struct cmd *, char *, size_t); +size_t cmd_send_keys_print(struct cmd *, char *, size_t); struct cmd_send_keys_data { char *target; @@ -160,7 +160,7 @@ cmd_send_keys_free(struct cmd *self) xfree(data); } -void +size_t cmd_send_keys_print(struct cmd *self, char *buf, size_t len) { struct cmd_send_keys_data *data = self->data; @@ -169,9 +169,9 @@ cmd_send_keys_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) - return; + return (off); if (off < len && data->target != NULL) - off += xsnprintf(buf + off, len - off, " -t %s", data->target); + off += cmd_prarg(buf + off, len - off, " -t ", data->target); if (off < len && data->idx != -1) off += xsnprintf(buf + off, len - off, " -i %d", data->idx); @@ -181,4 +181,5 @@ cmd_send_keys_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf + off, len - off, " %s", key_string_lookup_key(data->keys[i])); } + return (off); } diff --git a/cmd-set-password.c b/cmd-set-password.c index 583914c9..17817ac1 100644 --- a/cmd-set-password.c +++ b/cmd-set-password.c @@ -1,4 +1,4 @@ -/* $Id: cmd-set-password.c,v 1.1 2009-01-11 00:48:42 nicm Exp $ */ +/* $Id: cmd-set-password.c,v 1.2 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -33,7 +33,7 @@ void cmd_set_password_send(struct cmd *, struct buffer *); void cmd_set_password_recv(struct cmd *, struct buffer *); void cmd_set_password_free(struct cmd *); void cmd_set_password_init(struct cmd *, int); -void cmd_set_password_print(struct cmd *, char *, size_t); +size_t cmd_set_password_print(struct cmd *, char *, size_t); struct cmd_set_password_data { char *password; @@ -153,7 +153,7 @@ cmd_set_password_free(struct cmd *self) xfree(data); } -void +size_t cmd_set_password_print(struct cmd *self, char *buf, size_t len) { struct cmd_set_password_data *data = self->data; @@ -161,9 +161,10 @@ cmd_set_password_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) - return; + return (off); if (off < len && data->flag_encrypted) off += xsnprintf(buf + off, len - off, " -c"); if (off < len && data->password != NULL) off += xsnprintf(buf + off, len - off, " password"); + return (off); } diff --git a/cmd-set-window-option.c b/cmd-set-window-option.c index e0fe02cc..4b866712 100644 --- a/cmd-set-window-option.c +++ b/cmd-set-window-option.c @@ -1,4 +1,4 @@ -/* $Id: cmd-set-window-option.c,v 1.19 2009-01-10 19:35:39 nicm Exp $ */ +/* $Id: cmd-set-window-option.c,v 1.20 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -32,7 +32,7 @@ void cmd_set_window_option_exec(struct cmd *, struct cmd_ctx *); void cmd_set_window_option_send(struct cmd *, struct buffer *); void cmd_set_window_option_recv(struct cmd *, struct buffer *); void cmd_set_window_option_free(struct cmd *); -void cmd_set_window_option_print(struct cmd *, char *, size_t); +size_t cmd_set_window_option_print(struct cmd *, char *, size_t); const struct cmd_entry cmd_set_window_option_entry = { "set-window-option", "setw", diff --git a/cmd-source-file.c b/cmd-source-file.c index 900f7379..501eb060 100644 --- a/cmd-source-file.c +++ b/cmd-source-file.c @@ -1,4 +1,4 @@ -/* $Id: cmd-source-file.c,v 1.3 2009-01-07 08:10:02 nicm Exp $ */ +/* $Id: cmd-source-file.c,v 1.4 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2008 Tiago Cunha @@ -30,7 +30,7 @@ void cmd_source_file_send(struct cmd *, struct buffer *); void cmd_source_file_recv(struct cmd *, struct buffer *); void cmd_source_file_free(struct cmd *); void cmd_source_file_init(struct cmd *, int); -void cmd_source_file_print(struct cmd *, char *, size_t); +size_t cmd_source_file_print(struct cmd *, char *, size_t); struct cmd_source_file_data { char *path; @@ -133,7 +133,7 @@ cmd_source_file_free(struct cmd *self) xfree(data); } -void +size_t cmd_source_file_print(struct cmd *self, char *buf, size_t len) { struct cmd_source_file_data *data = self->data; @@ -141,7 +141,8 @@ cmd_source_file_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) - return; + return (off); if (off < len && data->path != NULL) - off += xsnprintf(buf + off, len - off, " %s", data->path); + off += cmd_prarg(buf + off, len - off, " ", data->path); + return (off); } diff --git a/cmd-split-window.c b/cmd-split-window.c index 9019932e..220e9225 100644 --- a/cmd-split-window.c +++ b/cmd-split-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-split-window.c,v 1.4 2009-01-14 19:29:32 nicm Exp $ */ +/* $Id: cmd-split-window.c,v 1.5 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott @@ -33,7 +33,7 @@ void cmd_split_window_send(struct cmd *, struct buffer *); void cmd_split_window_recv(struct cmd *, struct buffer *); void cmd_split_window_free(struct cmd *); void cmd_split_window_init(struct cmd *, int); -void cmd_split_window_print(struct cmd *, char *, size_t); +size_t cmd_split_window_print(struct cmd *, char *, size_t); struct cmd_split_window_data { char *target; @@ -185,7 +185,7 @@ cmd_split_window_free(struct cmd *self) xfree(data); } -void +size_t cmd_split_window_print(struct cmd *self, char *buf, size_t len) { struct cmd_split_window_data *data = self->data; @@ -193,11 +193,12 @@ cmd_split_window_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) - return; + return (off); if (off < len && data->flag_detached) off += xsnprintf(buf + off, len - off, " -d"); if (off < len && data->target != NULL) - off += xsnprintf(buf + off, len - off, " -t %s", data->target); + off += cmd_prarg(buf + off, len - off, " -t ", data->target); if (off < len && data->cmd != NULL) - off += xsnprintf(buf + off, len - off, " %s", data->cmd); + off += cmd_prarg(buf + off, len - off, " ", data->cmd); + return (off); } diff --git a/cmd-string.c b/cmd-string.c index c449c61c..2d7c5df0 100644 --- a/cmd-string.c +++ b/cmd-string.c @@ -1,4 +1,4 @@ -/* $Id: cmd-string.c,v 1.10 2009-01-10 01:51:21 nicm Exp $ */ +/* $Id: cmd-string.c,v 1.11 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -53,7 +53,7 @@ cmd_string_ungetc(unused const char *s, size_t *p) * string, or NULL for empty command. */ int -cmd_string_parse(const char *s, struct cmd **cmd, char **cause) +cmd_string_parse(const char *s, struct cmd_list **cmdlist, char **cause) { size_t p; int ch, argc, rval; @@ -67,7 +67,7 @@ cmd_string_parse(const char *s, struct cmd **cmd, char **cause) xasprintf(cause, "assignment failed: %s", s); return (-1); } - *cmd = NULL; + *cmdlist = NULL; return (0); } @@ -79,7 +79,7 @@ cmd_string_parse(const char *s, struct cmd **cmd, char **cause) *cause = NULL; - *cmd = NULL; + *cmdlist = NULL; rval = -1; p = 0; @@ -131,7 +131,8 @@ cmd_string_parse(const char *s, struct cmd **cmd, char **cause) if (argc == 0) goto out; - if ((*cmd = cmd_parse(argc, argv, cause)) == NULL) + *cmdlist = cmd_list_parse(argc, argv, cause); + if (*cmdlist == NULL) goto out; rval = 0; diff --git a/cmd-switch-client.c b/cmd-switch-client.c index 22db9aba..e9cc046f 100644 --- a/cmd-switch-client.c +++ b/cmd-switch-client.c @@ -1,4 +1,4 @@ -/* $Id: cmd-switch-client.c,v 1.13 2008-12-10 20:25:41 nicm Exp $ */ +/* $Id: cmd-switch-client.c,v 1.14 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -32,7 +32,7 @@ void cmd_switch_client_exec(struct cmd *, struct cmd_ctx *); void cmd_switch_client_send(struct cmd *, struct buffer *); void cmd_switch_client_recv(struct cmd *, struct buffer *); void cmd_switch_client_free(struct cmd *); -void cmd_switch_client_print(struct cmd *, char *, size_t); +size_t cmd_switch_client_print(struct cmd *, char *, size_t); struct cmd_switch_client_data { char *name; @@ -145,7 +145,7 @@ cmd_switch_client_free(struct cmd *self) xfree(data); } -void +size_t cmd_switch_client_print(struct cmd *self, char *buf, size_t len) { struct cmd_switch_client_data *data = self->data; @@ -153,9 +153,10 @@ cmd_switch_client_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) - return; + return (off); if (off < len && data->name != NULL) - off += xsnprintf(buf + off, len - off, " -c %s", data->name); + off += cmd_prarg(buf + off, len - off, " -c ", data->name); if (off < len && data->target != NULL) - off += xsnprintf(buf + off, len - off, " -t %s", data->target); + off += cmd_prarg(buf + off, len - off, " -t ", data->target); + return (off); } diff --git a/cmd.c b/cmd.c index 8e7a0e52..ad9eccdf 100644 --- a/cmd.c +++ b/cmd.c @@ -1,4 +1,4 @@ -/* $Id: cmd.c,v 1.80 2009-01-18 12:09:42 nicm Exp $ */ +/* $Id: cmd.c,v 1.81 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -234,6 +234,15 @@ cmd_free(struct cmd *cmd) xfree(cmd); } +size_t +cmd_print(struct cmd *cmd, char *buf, size_t len) +{ + if (cmd->entry->print == NULL) { + return (xsnprintf(buf, len, "%s", cmd->entry->name)); + } + return (cmd->entry->print(cmd, buf, len)); +} + void cmd_send_string(struct buffer *b, const char *s) { diff --git a/key-bindings.c b/key-bindings.c index 8b20000c..a616f04d 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -1,4 +1,4 @@ -/* $Id: key-bindings.c,v 1.54 2009-01-18 12:09:42 nicm Exp $ */ +/* $Id: key-bindings.c,v 1.55 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -44,7 +44,7 @@ key_bindings_lookup(int key) } void -key_bindings_add(int key, struct cmd *cmd) +key_bindings_add(int key, struct cmd_list *cmdlist) { struct key_binding *bd; @@ -53,8 +53,8 @@ key_bindings_add(int key, struct cmd *cmd) bd->key = key; SPLAY_INSERT(key_bindings, &key_bindings, bd); } else - cmd_free(bd->cmd); - bd->cmd = cmd; + cmd_list_free(bd->cmdlist); + bd->cmdlist = cmdlist; } void @@ -66,7 +66,7 @@ key_bindings_remove(int key) return; SPLAY_REMOVE(key_bindings, &key_bindings, bd); - cmd_free(bd->cmd); + cmd_list_free(bd->cmdlist); xfree(bd); } @@ -120,16 +120,22 @@ key_bindings_init(void) }; u_int i; struct cmd *cmd; + struct cmd_list *cmdlist; SPLAY_INIT(&key_bindings); for (i = 0; i < nitems(table); i++) { + cmdlist = xmalloc(sizeof *cmdlist); + TAILQ_INIT(cmdlist); + cmd = xmalloc(sizeof *cmd); cmd->entry = table[i].entry; cmd->data = NULL; if (cmd->entry->init != NULL) cmd->entry->init(cmd, table[i].key); - key_bindings_add(table[i].key, cmd); + TAILQ_INSERT_HEAD(cmdlist, cmd, qentry); + + key_bindings_add(table[i].key, cmdlist); } } @@ -141,7 +147,7 @@ key_bindings_free(void) while (!SPLAY_EMPTY(&key_bindings)) { bd = SPLAY_ROOT(&key_bindings); SPLAY_REMOVE(key_bindings, &key_bindings, bd); - cmd_free(bd->cmd); + cmd_list_free(bd->cmdlist); xfree(bd); } } @@ -207,5 +213,5 @@ key_bindings_dispatch(struct key_binding *bd, struct client *c) ctx.cmdclient = NULL; - cmd_exec(bd->cmd, &ctx); + cmd_list_exec(bd->cmdlist, &ctx); } diff --git a/server.c b/server.c index c5c482c5..37a3986f 100644 --- a/server.c +++ b/server.c @@ -1,4 +1,4 @@ -/* $Id: server.c,v 1.107 2009-01-18 12:09:42 nicm Exp $ */ +/* $Id: server.c,v 1.108 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -587,7 +587,8 @@ server_handle_client(struct client *c) struct window_pane *wp; struct timeval tv; struct key_binding *bd; - int key, prefix, status, flags, xtimeout; + struct cmd *cmd; + int key, prefix, status, xtimeout, can_repeat; xtimeout = options_get_number(&c->session->options, "repeat-time"); if (xtimeout != 0 && c->flags & CLIENT_REPEAT) { @@ -636,10 +637,16 @@ server_handle_client(struct client *c) } continue; } - flags = bd->cmd->entry->flags; + + /* Check repeat flag. */ + can_repeat = 1; + TAILQ_FOREACH(cmd, bd->cmdlist, qentry) { + if (!(cmd->entry->flags & CMD_CANREPEAT)) + can_repeat = 0; + } /* If already repeating, but this key can't repeat, skip it. */ - if (c->flags & CLIENT_REPEAT && !(flags & CMD_CANREPEAT)) { + if (c->flags & CLIENT_REPEAT && !can_repeat) { c->flags &= ~CLIENT_REPEAT; if (key == prefix) c->flags |= CLIENT_PREFIX; @@ -649,7 +656,7 @@ server_handle_client(struct client *c) } /* If this key can repeat, reset the repeat flags and timer. */ - if (xtimeout != 0 && flags & CMD_CANREPEAT) { + if (xtimeout != 0 && can_repeat) { c->flags |= CLIENT_PREFIX|CLIENT_REPEAT; tv.tv_sec = xtimeout / 1000; diff --git a/tmux.h b/tmux.h index eea4446b..b4db069e 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.237 2009-01-18 12:09:42 nicm Exp $ */ +/* $Id: tmux.h,v 1.238 2009-01-18 14:40:48 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -19,7 +19,7 @@ #ifndef TMUX_H #define TMUX_H -#define PROTOCOL_VERSION -8 +#define PROTOCOL_VERSION -9 /* Shut up gcc warnings about empty if bodies. */ #define RB_AUGMENT(x) do {} while (0) @@ -807,7 +807,10 @@ struct cmd_ctx { struct cmd { const struct cmd_entry *entry; void *data; + + TAILQ_ENTRY(cmd) qentry; }; +TAILQ_HEAD(cmd_list, cmd); struct cmd_entry { const char *name; @@ -832,7 +835,7 @@ struct cmd_entry { void (*send)(struct cmd *, struct buffer *); void (*recv)(struct cmd *, struct buffer *); void (*free)(struct cmd *); - void (*print)(struct cmd *, char *, size_t); + size_t (*print)(struct cmd *, char *, size_t); }; /* Generic command data. */ @@ -873,7 +876,7 @@ struct cmd_pane_data { /* Key binding. */ struct key_binding { int key; - struct cmd *cmd; + struct cmd_list *cmdlist; SPLAY_ENTRY(key_binding) entry; }; @@ -1080,6 +1083,7 @@ void cmd_exec(struct cmd *, struct cmd_ctx *); void cmd_send(struct cmd *, struct buffer *); struct cmd *cmd_recv(struct buffer *); void cmd_free(struct cmd *); +size_t cmd_print(struct cmd *, char *, size_t); void cmd_send_string(struct buffer *, const char *); char *cmd_recv_string(struct buffer *); struct session *cmd_current_session(struct cmd_ctx *); @@ -1149,10 +1153,19 @@ extern const struct cmd_entry cmd_unbind_key_entry; extern const struct cmd_entry cmd_unlink_window_entry; extern const struct cmd_entry cmd_up_pane_entry; +/* cmd-list.c */ +struct cmd_list *cmd_list_parse(int, char **, char **); +void cmd_list_exec(struct cmd_list *, struct cmd_ctx *); +void cmd_list_send(struct cmd_list *, struct buffer *); +struct cmd_list *cmd_list_recv(struct buffer *); +void cmd_list_free(struct cmd_list *); +size_t cmd_list_print(struct cmd_list *, char *, size_t); + /* cmd-string.c */ -int cmd_string_parse(const char *, struct cmd **, char **); +int cmd_string_parse(const char *, struct cmd_list **, char **); /* cmd-generic.c */ +size_t cmd_prarg(char *, size_t, const char *, char *); #define CMD_TARGET_WINDOW_USAGE "[-t target-window]" #define CMD_TARGET_SESSION_USAGE "[-t target-session]" #define CMD_TARGET_CLIENT_USAGE "[-t target-client]" @@ -1162,7 +1175,7 @@ void cmd_target_exec(struct cmd *, struct cmd_ctx *); void cmd_target_send(struct cmd *, struct buffer *); void cmd_target_recv(struct cmd *, struct buffer *); void cmd_target_free(struct cmd *); -void cmd_target_print(struct cmd *, char *, size_t); +size_t cmd_target_print(struct cmd *, char *, size_t); #define CMD_SRCDST_WINDOW_USAGE "[-s src-window] [-t dst-window]" #define CMD_SRCDST_SESSION_USAGE "[-s src-session] [-t dst-session]" #define CMD_SRCDST_CLIENT_USAGE "[-s src-client] [-t dst-client]" @@ -1172,7 +1185,7 @@ void cmd_srcdst_exec(struct cmd *, struct cmd_ctx *); void cmd_srcdst_send(struct cmd *, struct buffer *); void cmd_srcdst_recv(struct cmd *, struct buffer *); void cmd_srcdst_free(struct cmd *); -void cmd_srcdst_print(struct cmd *, char *, size_t); +size_t cmd_srcdst_print(struct cmd *, char *, size_t); #define CMD_BUFFER_WINDOW_USAGE "[-b buffer-index] [-t target-window]" #define CMD_BUFFER_SESSION_USAGE "[-b buffer-index] [-t target-session]" #define CMD_BUFFER_CLIENT_USAGE "[-b buffer-index] [-t target-client]" @@ -1182,7 +1195,7 @@ void cmd_buffer_exec(struct cmd *, struct cmd_ctx *); void cmd_buffer_send(struct cmd *, struct buffer *); void cmd_buffer_recv(struct cmd *, struct buffer *); void cmd_buffer_free(struct cmd *); -void cmd_buffer_print(struct cmd *, char *, size_t); +size_t cmd_buffer_print(struct cmd *, char *, size_t); #define CMD_OPTION_WINDOW_USAGE "[-gu] [-t target-window] option [value]" #define CMD_OPTION_SESSION_USAGE "[-gu] [-t target-session] option [value]" #define CMD_OPTION_CLIENT_USAGE "[-gu] [-t target-client] option [value]" @@ -1192,7 +1205,7 @@ void cmd_option_exec(struct cmd *, struct cmd_ctx *); void cmd_option_send(struct cmd *, struct buffer *); void cmd_option_recv(struct cmd *, struct buffer *); void cmd_option_free(struct cmd *); -void cmd_option_print(struct cmd *, char *, size_t); +size_t cmd_option_print(struct cmd *, char *, size_t); #define CMD_PANE_WINDOW_USAGE "[-t target-window] [-p pane-index]" #define CMD_PANE_SESSION_USAGE "[-t target-session] [-p pane-index]" #define CMD_PANE_CLIENT_USAGE "[-t target-client] [-p pane-index]" @@ -1202,7 +1215,7 @@ void cmd_pane_exec(struct cmd *, struct cmd_ctx *); void cmd_pane_send(struct cmd *, struct buffer *); void cmd_pane_recv(struct cmd *, struct buffer *); void cmd_pane_free(struct cmd *); -void cmd_pane_print(struct cmd *, char *, size_t); +size_t cmd_pane_print(struct cmd *, char *, size_t); /* client.c */ int client_init(const char *, struct client_ctx *, int, int); @@ -1223,7 +1236,7 @@ extern struct key_bindings key_bindings; int key_bindings_cmp(struct key_binding *, struct key_binding *); SPLAY_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp); struct key_binding *key_bindings_lookup(int); -void key_bindings_add(int, struct cmd *); +void key_bindings_add(int, struct cmd_list *); void key_bindings_remove(int); void key_bindings_init(void); void key_bindings_free(void); -- cgit v1.2.3