diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-01-04 00:42:48 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2011-01-04 00:42:48 +0000 |
commit | 16cb3f3755ad38847f98c31f447e46392ac712fa (patch) | |
tree | 38c22cdaf8c376adff22781d854c9c5c67ed42ed /usr.bin/tmux/cmd-rotate-window.c | |
parent | 8e6a3ab86e7918f82355f33fa944cca1df578195 (diff) |
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 'usr.bin/tmux/cmd-rotate-window.c')
-rw-r--r-- | usr.bin/tmux/cmd-rotate-window.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/usr.bin/tmux/cmd-rotate-window.c b/usr.bin/tmux/cmd-rotate-window.c index 13d178ef95a..f24294e6eda 100644 --- a/usr.bin/tmux/cmd-rotate-window.c +++ b/usr.bin/tmux/cmd-rotate-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-rotate-window.c,v 1.10 2009/11/13 19:53:29 nicm Exp $ */ +/* $OpenBSD: cmd-rotate-window.c,v 1.11 2011/01/04 00:42:47 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -24,47 +24,42 @@ * Rotate the panes in a window. */ -void cmd_rotate_window_init(struct cmd *, int); +void cmd_rotate_window_key_binding(struct cmd *, int); int cmd_rotate_window_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_rotate_window_entry = { "rotate-window", "rotatew", + "Dt:U", 0, 0, "[-DU] " CMD_TARGET_WINDOW_USAGE, - 0, "DU", - cmd_rotate_window_init, - cmd_target_parse, - cmd_rotate_window_exec, - cmd_target_free, - cmd_target_print + 0, + cmd_rotate_window_key_binding, + NULL, + cmd_rotate_window_exec }; void -cmd_rotate_window_init(struct cmd *self, int key) +cmd_rotate_window_key_binding(struct cmd *self, int key) { - struct cmd_target_data *data; - - cmd_target_init(self, key); - data = self->data; - + self->args = args_create(0); if (key == ('o' | KEYC_ESCAPE)) - cmd_set_flag(&data->chflags, 'D'); + args_set(self->args, 'D', NULL); } int cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx) { - struct cmd_target_data *data = self->data; + struct args *args = self->args; struct winlink *wl; struct window *w; struct window_pane *wp, *wp2; struct layout_cell *lc; u_int sx, sy, xoff, yoff; - if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) + if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL) return (-1); w = wl->window; - if (cmd_check_flag(data->chflags, 'D')) { + if (args_has(self->args, 'D')) { wp = TAILQ_LAST(&w->panes, window_panes); TAILQ_REMOVE(&w->panes, wp, entry); TAILQ_INSERT_HEAD(&w->panes, wp, entry); |