summaryrefslogtreecommitdiffstats
path: root/cmd-rotate-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2011-01-04 00:42:46 +0000
committerNicholas Marriott <nicm@openbsd.org>2011-01-04 00:42:46 +0000
commit7502cb3adbb26a2f94445a35626e64041d6769f9 (patch)
tree6ae4f33f69dc0a470dbe905b5140216fb19b8f01 /cmd-rotate-window.c
parentac3b78a84178a308536a56ea114b0f6f8ce6fb47 (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 'cmd-rotate-window.c')
-rw-r--r--cmd-rotate-window.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/cmd-rotate-window.c b/cmd-rotate-window.c
index fbfba099..1d752e74 100644
--- a/cmd-rotate-window.c
+++ b/cmd-rotate-window.c
@@ -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);