From ee1a7fded7653ffc2ba68a4188c89a7cb6e1bf1d Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 5 Jun 2008 17:12:11 +0000 Subject: [PATCH] Print for the less easy commands. --- TODO | 8 +++++++ cmd-attach-session.c | 22 ++++++++++++++++-- cmd-generic.c | 20 ++++++++--------- cmd-link-window.c | 50 +++++++++++++++++++++++++++++++---------- cmd-new-session.c | 10 +++++++-- cmd-new-window.c | 30 ++++++++++++++++++++++--- cmd-rename-session.c | 12 +++++++--- cmd-rename-window.c | 24 ++++++++++++++++++-- cmd-send-keys.c | 29 ++++++++++++++++++++++-- cmd-set-option.c | 20 +++++++++++++++-- cmd-set-window-option.c | 20 +++++++++++++++-- cmd-swap-window.c | 46 ++++++++++++++++++++++++++++--------- cmd-switch-client.c | 20 +++++++++++++++-- 13 files changed, 258 insertions(+), 53 deletions(-) diff --git a/TODO b/TODO index d3122dfa..c5effd8c 100644 --- a/TODO +++ b/TODO @@ -83,3 +83,11 @@ - each command should have a print op as well for list keys - fix occasion start server problems - test and fix wsvt25 +- look again at stuff that doesn't use flags + swap-window + switch-client +audit for lookup window + link-window + look for dstidx + also lookup dstsess with find_session +--- diff --git a/cmd-attach-session.c b/cmd-attach-session.c index d4d3367e..820584b7 100644 --- a/cmd-attach-session.c +++ b/cmd-attach-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-attach-session.c,v 1.16 2008-06-05 16:35:31 nicm Exp $ */ +/* $Id: cmd-attach-session.c,v 1.17 2008-06-05 17:12:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -31,6 +31,7 @@ void cmd_attach_session_exec(struct cmd *, struct cmd_ctx *); void cmd_attach_session_send(struct cmd *, struct buffer *); void cmd_attach_session_recv(struct cmd *, struct buffer *); void cmd_attach_session_free(struct cmd *); +void cmd_attach_session_print(struct cmd *, char *, size_t); struct cmd_attach_session_data { char *cname; @@ -48,7 +49,7 @@ const struct cmd_entry cmd_attach_session_entry = { cmd_attach_session_recv, cmd_attach_session_free, NULL, - NULL + cmd_attach_session_print }; int @@ -162,3 +163,20 @@ cmd_attach_session_free(struct cmd *self) xfree(data->sname); xfree(data); } + +void +cmd_attach_session_print(struct cmd *self, char *buf, size_t len) +{ + struct cmd_attach_session_data *data = self->data; + size_t off = 0; + + off += xsnprintf(buf, len, "%s", self->entry->name); + if (data == NULL) + return; + if (off < len && data->flag_detach) + off += xsnprintf(buf + off, len - off, " -d"); + if (off < len && data->cname != NULL) + off += xsnprintf(buf + off, len - off, " -c %s", data->cname); + if (off < len && data->sname != NULL) + off += xsnprintf(buf + off, len - off, " -s %s", data->sname); +} diff --git a/cmd-generic.c b/cmd-generic.c index b045a7ee..8eece27b 100644 --- a/cmd-generic.c +++ b/cmd-generic.c @@ -1,4 +1,4 @@ -/* $Id: cmd-generic.c,v 1.6 2008-06-05 16:35:31 nicm Exp $ */ +/* $Id: cmd-generic.c,v 1.7 2008-06-05 17:12:10 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -101,11 +101,11 @@ cmd_clientonly_print(struct cmd *self, char *buf, size_t len) struct cmd_clientonly_data *data = self->data; size_t off = 0; - off += xsnprintf(buf, len, "%s ", self->entry->name); + off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) return; if (off < len && data->cname != NULL) - off += xsnprintf(buf + off, len - off, "-c %s ", data->cname); + off += xsnprintf(buf + off, len - off, " -c %s", data->cname); } int @@ -199,13 +199,13 @@ cmd_sessiononly_print(struct cmd *self, char *buf, size_t len) struct cmd_sessiononly_data *data = self->data; size_t off = 0; - off += xsnprintf(buf, len, "%s ", self->entry->name); + off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) return; if (off < len && data->cname != NULL) - off += xsnprintf(buf + off, len - off, "-c %s ", data->cname); + off += xsnprintf(buf + off, len - off, " -c %s", data->cname); if (off < len && data->sname != NULL) - off += xsnprintf(buf + off, len - off, "-s %s ", data->sname); + off += xsnprintf(buf + off, len - off, " -s %s", data->sname); } int @@ -313,13 +313,13 @@ cmd_windowonly_print(struct cmd *self, char *buf, size_t len) struct cmd_windowonly_data *data = self->data; size_t off = 0; - off += xsnprintf(buf, len, "%s ", self->entry->name); + off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) return; if (off < len && data->cname != NULL) - off += xsnprintf(buf + off, len - off, "-c %s ", data->cname); + off += xsnprintf(buf + off, len - off, " -c %s", data->cname); if (off < len && data->sname != NULL) - off += xsnprintf(buf + off, len - off, "-s %s ", data->sname); + off += xsnprintf(buf + off, len - off, " -s %s", data->sname); if (off < len && data->idx != -1) - off += xsnprintf(buf + off, len - off, "-i %d ", data->idx); + off += xsnprintf(buf + off, len - off, " -i %d", data->idx); } diff --git a/cmd-link-window.c b/cmd-link-window.c index 9888d389..7bdd84c1 100644 --- a/cmd-link-window.c +++ b/cmd-link-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-link-window.c,v 1.17 2008-06-05 16:35:31 nicm Exp $ */ +/* $Id: cmd-link-window.c,v 1.18 2008-06-05 17:12:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -32,13 +32,14 @@ void cmd_link_window_exec(struct cmd *, struct cmd_ctx *); void cmd_link_window_send(struct cmd *, struct buffer *); void cmd_link_window_recv(struct cmd *, struct buffer *); void cmd_link_window_free(struct cmd *); +void cmd_link_window_print(struct cmd *, char *, size_t); struct cmd_link_window_data { char *cname; char *sname; + int idx; int flag_detached; int flag_kill; - int dstidx; int srcidx; char *srcname; }; @@ -53,7 +54,7 @@ const struct cmd_entry cmd_link_window_entry = { cmd_link_window_recv, cmd_link_window_free, NULL, - NULL + cmd_link_window_print }; int @@ -68,7 +69,7 @@ cmd_link_window_parse(struct cmd *self, int argc, char **argv, char **cause) data->sname = NULL; data->flag_detached = 0; data->flag_kill = 0; - data->dstidx = -1; + data->idx = -1; data->srcidx = -1; data->srcname = NULL; @@ -84,7 +85,7 @@ cmd_link_window_parse(struct cmd *self, int argc, char **argv, char **cause) data->flag_detached = 1; break; case 'i': - data->dstidx = strtonum(optarg, 0, INT_MAX, &errstr); + data->idx = strtonum(optarg, 0, INT_MAX, &errstr); if (errstr != NULL) { xasprintf(cause, "index %s", errstr); goto error; @@ -155,12 +156,12 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx) } } - if (data->dstidx < 0) - data->dstidx = -1; - if (data->flag_kill && data->dstidx != -1) { - wl2 = winlink_find_by_index(&s->windows, data->dstidx); + if (data->idx < 0) + data->idx = -1; + if (data->flag_kill && data->idx != -1) { + wl2 = winlink_find_by_index(&s->windows, data->idx); if (wl2 == NULL) { - ctx->error(ctx, "no window %d", data->dstidx); + ctx->error(ctx, "no window %d", data->idx); return; } @@ -185,9 +186,9 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx) */ } - wl = session_attach(s, wl->window, data->dstidx); + wl = session_attach(s, wl->window, data->idx); if (wl == NULL) { - ctx->error(ctx, "index in use: %d", data->dstidx); + ctx->error(ctx, "index in use: %d", data->idx); return; } @@ -237,3 +238,28 @@ cmd_link_window_free(struct cmd *self) xfree(data->srcname); xfree(data); } + +void +cmd_link_window_print(struct cmd *self, char *buf, size_t len) +{ + struct cmd_link_window_data *data = self->data; + size_t off = 0; + + off += xsnprintf(buf, len, "%s", self->entry->name); + if (data == NULL) + return; + if (off < len && data->flag_detached) + off += xsnprintf(buf + off, len - off, " -d"); + if (off < len && data->flag_kill) + off += xsnprintf(buf + off, len - off, " -k"); + if (off < len && data->cname != NULL) + off += xsnprintf(buf + off, len - off, " -c %s", data->cname); + if (off < len && data->sname != NULL) + off += xsnprintf(buf + off, len - off, " -s %s", data->sname); + if (off < len && data->idx != -1) + off += xsnprintf(buf + off, len - off, " -i %d", data->idx); + if (off < len && data->srcname != NULL) + off += xsnprintf(buf + off, len - off, " %s", data->srcname); + if (off < len && data->srcidx != -1) + off += xsnprintf(buf + off, len - off, " %d", data->srcidx); +} diff --git a/cmd-new-session.c b/cmd-new-session.c index adff55e4..3d598ca4 100644 --- a/cmd-new-session.c +++ b/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-new-session.c,v 1.25 2008-06-05 16:35:31 nicm Exp $ */ +/* $Id: cmd-new-session.c,v 1.26 2008-06-05 17:12:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -32,6 +32,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); struct cmd_new_session_data { char *name; @@ -50,7 +51,7 @@ const struct cmd_entry cmd_new_session_entry = { cmd_new_session_recv, cmd_new_session_free, cmd_new_session_init, - NULL + cmd_new_session_print }; void @@ -210,3 +211,8 @@ cmd_new_session_free(struct cmd *self) xfree(data->cmd); xfree(data); } + +void +cmd_new_session_print(struct cmd *cmd, char *buf, size_t len) +{ +} diff --git a/cmd-new-window.c b/cmd-new-window.c index adfea267..9cc3fc3d 100644 --- a/cmd-new-window.c +++ b/cmd-new-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-new-window.c,v 1.21 2008-06-05 16:35:31 nicm Exp $ */ +/* $Id: cmd-new-window.c,v 1.22 2008-06-05 17:12:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -33,13 +33,14 @@ 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); struct cmd_new_window_data { char *cname; char *sname; + int idx; char *name; char *cmd; - int idx; int flag_detached; }; @@ -53,7 +54,7 @@ const struct cmd_entry cmd_new_window_entry = { cmd_new_window_recv, cmd_new_window_free, cmd_new_window_init, - NULL + cmd_new_window_print }; void @@ -202,3 +203,26 @@ cmd_new_window_free(struct cmd *self) xfree(data->cmd); xfree(data); } + +void +cmd_new_window_print(struct cmd *self, char *buf, size_t len) +{ + struct cmd_new_window_data *data = self->data; + size_t off = 0; + + off += xsnprintf(buf, len, "%s", self->entry->name); + if (data == NULL) + return; + if (off < len && data->flag_detached) + off += xsnprintf(buf + off, len - off, " -d"); + if (off < len && data->cname != NULL) + off += xsnprintf(buf + off, len - off, " -c %s", data->cname); + if (off < len && data->sname != NULL) + off += xsnprintf(buf + off, len - off, " -s %s", data->sname); + if (off < len && data->idx != -1) + off += xsnprintf(buf + off, len - off, " -i %d", data->idx); + if (off < len && data->name != NULL) + off += xsnprintf(buf + off, len - off, " -n %s", data->name); + if (off < len && data->cmd != NULL) + off += xsnprintf(buf + off, len - off, " %s", data->cmd); +} diff --git a/cmd-rename-session.c b/cmd-rename-session.c index 63314618..904963b8 100644 --- a/cmd-rename-session.c +++ b/cmd-rename-session.c @@ -1,4 +1,4 @@ -/* $Id: cmd-rename-session.c,v 1.9 2008-06-05 16:35:32 nicm Exp $ */ +/* $Id: cmd-rename-session.c,v 1.10 2008-06-05 17:12:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -32,6 +32,7 @@ void cmd_rename_session_exec(struct cmd *, struct cmd_ctx *); void cmd_rename_session_send(struct cmd *, struct buffer *); void cmd_rename_session_recv(struct cmd *, struct buffer *); void cmd_rename_session_free(struct cmd *); +void cmd_rename_session_print(struct cmd *, char *, size_t); struct cmd_rename_session_data { char *cname; @@ -42,14 +43,14 @@ struct cmd_rename_session_data { const struct cmd_entry cmd_rename_session_entry = { "rename-session", "rename", "[-c client-tty|-s session-name] new-name", - 0, + 0, cmd_rename_session_parse, cmd_rename_session_exec, cmd_rename_session_send, cmd_rename_session_recv, cmd_rename_session_free, NULL, - NULL + cmd_rename_session_print }; int @@ -152,3 +153,8 @@ cmd_rename_session_free(struct cmd *self) xfree(data->newname); xfree(data); } + +void +cmd_rename_session_print(struct cmd *cmd, char *buf, size_t len) +{ +} diff --git a/cmd-rename-window.c b/cmd-rename-window.c index 7bc26d20..145683cf 100644 --- a/cmd-rename-window.c +++ b/cmd-rename-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-rename-window.c,v 1.20 2008-06-05 16:35:32 nicm Exp $ */ +/* $Id: cmd-rename-window.c,v 1.21 2008-06-05 17:12:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -32,6 +32,7 @@ void cmd_rename_window_exec(struct cmd *, struct cmd_ctx *); void cmd_rename_window_send(struct cmd *, struct buffer *); void cmd_rename_window_recv(struct cmd *, struct buffer *); void cmd_rename_window_free(struct cmd *); +void cmd_rename_window_print(struct cmd *, char *, size_t); struct cmd_rename_window_data { char *cname; @@ -50,7 +51,7 @@ const struct cmd_entry cmd_rename_window_entry = { cmd_rename_window_recv, cmd_rename_window_free, NULL, - NULL + cmd_rename_window_print }; int @@ -167,3 +168,22 @@ cmd_rename_window_free(struct cmd *self) xfree(data->newname); xfree(data); } + +void +cmd_rename_window_print(struct cmd *self, char *buf, size_t len) +{ + struct cmd_rename_window_data *data = self->data; + size_t off = 0; + + off += xsnprintf(buf, len, "%s", self->entry->name); + if (data == NULL) + return; + if (off < len && data->cname != NULL) + off += xsnprintf(buf + off, len - off, " -c %s", data->cname); + if (off < len && data->sname != NULL) + off += xsnprintf(buf + off, len - off, " -s %s", data->sname); + if (off < len && data->idx != -1) + off += xsnprintf(buf + off, len - off, " -i %d", data->idx); + if (off < len && data->newname != NULL) + off += xsnprintf(buf + off, len - off, " %s", data->newname); +} diff --git a/cmd-send-keys.c b/cmd-send-keys.c index 95ad63cb..e0a85406 100644 --- a/cmd-send-keys.c +++ b/cmd-send-keys.c @@ -1,4 +1,4 @@ -/* $Id: cmd-send-keys.c,v 1.8 2008-06-05 16:35:32 nicm Exp $ */ +/* $Id: cmd-send-keys.c,v 1.9 2008-06-05 17:12:10 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -32,6 +32,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); struct cmd_send_keys_data { char *cname; @@ -51,7 +52,7 @@ const struct cmd_entry cmd_send_keys_entry = { cmd_send_keys_recv, cmd_send_keys_free, NULL, - NULL + cmd_send_keys_print }; int @@ -181,3 +182,27 @@ cmd_send_keys_free(struct cmd *self) xfree(data->sname); xfree(data); } + +void +cmd_send_keys_print(struct cmd *self, char *buf, size_t len) +{ + struct cmd_send_keys_data *data = self->data; + size_t off = 0; + u_int i; + + off += xsnprintf(buf, len, "%s", self->entry->name); + if (data == NULL) + return; + off += xsnprintf(buf + off, len - off, " -c %s", data->cname); + if (off < len && data->sname != NULL) + off += xsnprintf(buf + off, len - off, " -s %s", data->sname); + if (off < len && data->idx != -1) + off += xsnprintf(buf + off, len - off, " -i %d", data->idx); + + for (i = 0; i < data->nkeys; i++) { + if (off >= len) + break; + off += xsnprintf(buf + off, + len - off, " %s", key_string_lookup_key(data->keys[i])); + } +} diff --git a/cmd-set-option.c b/cmd-set-option.c index 1b985103..a1ac9a9f 100644 --- a/cmd-set-option.c +++ b/cmd-set-option.c @@ -1,4 +1,4 @@ -/* $Id: cmd-set-option.c,v 1.23 2008-06-05 16:35:32 nicm Exp $ */ +/* $Id: cmd-set-option.c,v 1.24 2008-06-05 17:12:11 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -33,6 +33,7 @@ void cmd_set_option_exec(struct cmd *, struct cmd_ctx *); void cmd_set_option_send(struct cmd *, struct buffer *); void cmd_set_option_recv(struct cmd *, struct buffer *); void cmd_set_option_free(struct cmd *); +void cmd_set_option_print(struct cmd *, char *, size_t); struct cmd_set_option_data { char *cname; @@ -52,7 +53,7 @@ const struct cmd_entry cmd_set_option_entry = { cmd_set_option_recv, cmd_set_option_free, NULL, - NULL + cmd_set_option_print }; int @@ -315,3 +316,18 @@ cmd_set_option_free(struct cmd *self) xfree(data->value); xfree(data); } + +void +cmd_set_option_print(struct cmd *self, char *buf, size_t len) +{ + struct cmd_set_option_data *data = self->data; + size_t off = 0; + + off += xsnprintf(buf, len, "%s", self->entry->name); + if (data == NULL) + return; + 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); +} diff --git a/cmd-set-window-option.c b/cmd-set-window-option.c index 29caa39f..b91596e5 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.3 2008-06-05 16:35:32 nicm Exp $ */ +/* $Id: cmd-set-window-option.c,v 1.4 2008-06-05 17:12:11 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -33,6 +33,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); struct cmd_set_window_option_data { char *cname; @@ -52,7 +53,7 @@ const struct cmd_entry cmd_set_window_option_entry = { cmd_set_window_option_recv, cmd_set_window_option_free, NULL, - NULL + cmd_set_window_option_print }; int @@ -222,3 +223,18 @@ cmd_set_window_option_free(struct cmd *self) xfree(data->value); xfree(data); } + +void +cmd_set_window_option_print(struct cmd *self, char *buf, size_t len) +{ + struct cmd_set_window_option_data *data = self->data; + size_t off = 0; + + off += xsnprintf(buf, len, "%s", self->entry->name); + if (data == NULL) + return; + 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); +} diff --git a/cmd-swap-window.c b/cmd-swap-window.c index 1b210278..bb567b79 100644 --- a/cmd-swap-window.c +++ b/cmd-swap-window.c @@ -1,4 +1,4 @@ -/* $Id: cmd-swap-window.c,v 1.9 2008-06-05 16:35:32 nicm Exp $ */ +/* $Id: cmd-swap-window.c,v 1.10 2008-06-05 17:12:11 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -32,11 +32,12 @@ void cmd_swap_window_exec(struct cmd *, struct cmd_ctx *); void cmd_swap_window_send(struct cmd *, struct buffer *); void cmd_swap_window_recv(struct cmd *, struct buffer *); void cmd_swap_window_free(struct cmd *); +void cmd_swap_window_print(struct cmd *, char *, size_t); struct cmd_swap_window_data { char *cname; char *sname; - int dstidx; + int idx; int srcidx; char *srcname; int flag_detached; @@ -44,7 +45,7 @@ struct cmd_swap_window_data { const struct cmd_entry cmd_swap_window_entry = { "swap-window", "swapw", - "[-c client-tty|-s session-name] [-i index] session-name index", + "[-d] [-c client-tty|-s session-name] [-i index] session-name index", 0, cmd_swap_window_parse, cmd_swap_window_exec, @@ -52,7 +53,7 @@ const struct cmd_entry cmd_swap_window_entry = { cmd_swap_window_recv, cmd_swap_window_free, NULL, - NULL + cmd_swap_window_print }; int @@ -66,7 +67,7 @@ cmd_swap_window_parse(struct cmd *self, int argc, char **argv, char **cause) data->cname = NULL; data->sname = NULL; data->flag_detached = 0; - data->dstidx = -1; + data->idx = -1; data->srcidx = -1; data->srcname = NULL; @@ -82,7 +83,7 @@ cmd_swap_window_parse(struct cmd *self, int argc, char **argv, char **cause) data->flag_detached = 1; break; case 'i': - data->dstidx = strtonum(optarg, 0, INT_MAX, &errstr); + data->idx = strtonum(optarg, 0, INT_MAX, &errstr); if (errstr != NULL) { xasprintf(cause, "index %s", errstr); goto error; @@ -151,14 +152,14 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx) } } - if (data->dstidx < 0) - data->dstidx = -1; - if (data->dstidx == -1) + if (data->idx < 0) + data->idx = -1; + if (data->idx == -1) dstwl = s->curw; else { - dstwl = winlink_find_by_index(&s->windows, data->dstidx); + dstwl = winlink_find_by_index(&s->windows, data->idx); if (dstwl == NULL) { - ctx->error(ctx, "no window %d", data->dstidx); + ctx->error(ctx, "no window %d", data->idx); return; } } @@ -216,3 +217,26 @@ cmd_swap_window_free(struct cmd *self) xfree(data->srcname); xfree(data); } + +void +cmd_swap_window_print(struct cmd *self, char *buf, size_t len) +{ + struct cmd_swap_window_data *data = self->data; + size_t off = 0; + + off += xsnprintf(buf, len, "%s", self->entry->name); + if (data == NULL) + return; + if (off < len && data->flag_detached) + off += xsnprintf(buf + off, len - off, " -d"); + if (off < len && data->cname != NULL) + off += xsnprintf(buf + off, len - off, " -c %s", data->cname); + if (off < len && data->sname != NULL) + off += xsnprintf(buf + off, len - off, " -s %s", data->sname); + if (off < len && data->idx != -1) + off += xsnprintf(buf + off, len - off, " -i %d", data->idx); + if (off < len && data->srcname != NULL) + off += xsnprintf(buf + off, len - off, " %s", data->srcname); + if (off < len && data->srcidx != -1) + off += xsnprintf(buf + off, len - off, " %d", data->srcidx); +} diff --git a/cmd-switch-client.c b/cmd-switch-client.c index 0b96e364..ddff1fef 100644 --- a/cmd-switch-client.c +++ b/cmd-switch-client.c @@ -1,4 +1,4 @@ -/* $Id: cmd-switch-client.c,v 1.7 2008-06-05 16:35:32 nicm Exp $ */ +/* $Id: cmd-switch-client.c,v 1.8 2008-06-05 17:12:11 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -33,6 +33,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); struct cmd_switch_client_data { char *cname; @@ -49,7 +50,7 @@ const struct cmd_entry cmd_switch_client_entry = { cmd_switch_client_recv, cmd_switch_client_free, NULL, - NULL + cmd_switch_client_print }; int @@ -145,3 +146,18 @@ cmd_switch_client_free(struct cmd *self) xfree(data->name); xfree(data); } + +void +cmd_switch_client_print(struct cmd *self, char *buf, size_t len) +{ + struct cmd_switch_client_data *data = self->data; + size_t off = 0; + + off += xsnprintf(buf, len, "%s", self->entry->name); + if (data == NULL) + return; + if (off < len && data->cname != NULL) + off += xsnprintf(buf + off, len - off, " -c %s", data->cname); + if (off < len && data->name != NULL) + off += xsnprintf(buf + off, len - off, " %s", data->name); +}