diff options
-rw-r--r-- | CHANGES | 15 | ||||
-rw-r--r-- | GNUmakefile | 4 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | TODO | 6 | ||||
-rw-r--r-- | cfg.c | 22 | ||||
-rw-r--r-- | cmd-bind-key.c | 38 | ||||
-rw-r--r-- | cmd-command-prompt.c | 14 | ||||
-rw-r--r-- | cmd-generic.c | 52 | ||||
-rw-r--r-- | cmd-list-keys.c | 14 | ||||
-rw-r--r-- | cmd-list.c | 137 | ||||
-rw-r--r-- | cmd-new-session.c | 15 | ||||
-rw-r--r-- | cmd-new-window.c | 15 | ||||
-rw-r--r-- | cmd-send-keys.c | 11 | ||||
-rw-r--r-- | cmd-set-password.c | 9 | ||||
-rw-r--r-- | cmd-set-window-option.c | 4 | ||||
-rw-r--r-- | cmd-source-file.c | 11 | ||||
-rw-r--r-- | cmd-split-window.c | 13 | ||||
-rw-r--r-- | cmd-string.c | 11 | ||||
-rw-r--r-- | cmd-switch-client.c | 13 | ||||
-rw-r--r-- | cmd.c | 11 | ||||
-rw-r--r-- | key-bindings.c | 22 | ||||
-rw-r--r-- | server.c | 17 | ||||
-rw-r--r-- | tmux.h | 35 |
23 files changed, 350 insertions, 143 deletions
@@ -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 \ @@ -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 \ @@ -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 @@ -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 <nicm@users.sourceforge.net> @@ -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 <nicm@users.sourceforge.net> @@ -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 <nicm@users.sourceforge.net> @@ -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 <nicm@users.sourceforge.net> @@ -19,6 +19,7 @@ #include <sys/types.h> #include <stdlib.h> +#include <string.h> #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 <nicm@users.sourceforge.net> @@ -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 <nicm@users.sourceforge.net> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/types.h> + +#include <string.h> + +#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 <nicm@users.sourceforge.net> @@ -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 <nicm@users.sourceforge.net> @@ -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 <nicm@users.sourceforge.net> @@ -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 <nicm@users.sourceforge.net> @@ -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 <nicm@users.sourceforge.net> @@ -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 <me@tiagocunha.org> @@ -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 <nicm@users.sourceforge.net> @@ -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 |