diff options
author | Tiago Cunha <tcunha@gmx.com> | 2011-01-07 14:45:34 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2011-01-07 14:45:34 +0000 |
commit | 1df427bc7b1a458f4d3fe6f9255010708a8d8634 (patch) | |
tree | 6d47a72a426bb3e18146c682591d398607a8a211 /cmd-choose-buffer.c | |
parent | 219442cff707a1febb6a75ba2cfe48b02ae0a22e (diff) |
Sync OpenBSD patchset 829:
Clean up and simplify tmux command argument parsing.
Originally, tmux commands were parsed in the client process into a
struct with the command data which was then serialised and sent to the
server to be executed. The parsing was later moved into the server (an
argv was sent from the client), but the parse step and intermediate
struct was kept.
This change removes that struct and the separate parse step. Argument
parsing and printing is now common to all commands (in arguments.c) with
each command left with just an optional check function (to validate the
arguments at parse time), the exec function and a function to set up any
key bindings (renamed from the old init function).
This is overall more simple and consistent.
There should be no changes to any commands behaviour or syntax although
as this touches every command please watch for any unexpected changes.
Diffstat (limited to 'cmd-choose-buffer.c')
-rw-r--r-- | cmd-choose-buffer.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/cmd-choose-buffer.c b/cmd-choose-buffer.c index 8ac9230c..d6a27b4a 100644 --- a/cmd-choose-buffer.c +++ b/cmd-choose-buffer.c @@ -1,4 +1,4 @@ -/* $Id: cmd-choose-buffer.c,v 1.3 2011-01-03 23:26:14 tcunha Exp $ */ +/* $Id: cmd-choose-buffer.c,v 1.4 2011-01-07 14:45:33 tcunha Exp $ */ /* * Copyright (c) 2010 Nicholas Marriott <nicm@users.sourceforge.net> @@ -33,24 +33,23 @@ void cmd_choose_buffer_free(void *); const struct cmd_entry cmd_choose_buffer_entry = { "choose-buffer", NULL, + "t:", 0, 1, CMD_TARGET_WINDOW_USAGE " [template]", - CMD_ARG01, "", - cmd_target_init, - cmd_target_parse, - cmd_choose_buffer_exec, - cmd_target_free, - cmd_target_print + 0, + NULL, + NULL, + cmd_choose_buffer_exec }; struct cmd_choose_buffer_data { - struct client *client; - char *template; + struct client *client; + char *template; }; int cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) { - struct cmd_target_data *data = self->data; + struct args *args = self->args; struct cmd_choose_buffer_data *cdata; struct winlink *wl; struct paste_buffer *pb; @@ -62,7 +61,7 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) return (-1); } - if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) + if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) return (-1); if (paste_get_top(&global_buffers) == NULL) @@ -80,8 +79,8 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) } cdata = xmalloc(sizeof *cdata); - if (data->arg != NULL) - cdata->template = xstrdup(data->arg); + if (args->argc != 0) + cdata->template = xstrdup(args->argv[0]); else cdata->template = xstrdup("paste-buffer -b '%%'"); cdata->client = ctx->curclient; |