summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-clear-history.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2011-01-04 00:42:48 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2011-01-04 00:42:48 +0000
commit16cb3f3755ad38847f98c31f447e46392ac712fa (patch)
tree38c22cdaf8c376adff22781d854c9c5c67ed42ed /usr.bin/tmux/cmd-clear-history.c
parent8e6a3ab86e7918f82355f33fa944cca1df578195 (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-clear-history.c')
-rw-r--r--usr.bin/tmux/cmd-clear-history.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/usr.bin/tmux/cmd-clear-history.c b/usr.bin/tmux/cmd-clear-history.c
index ffb88022f6a..2b0378d724d 100644
--- a/usr.bin/tmux/cmd-clear-history.c
+++ b/usr.bin/tmux/cmd-clear-history.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-clear-history.c,v 1.7 2009/11/13 19:53:28 nicm Exp $ */
+/* $OpenBSD: cmd-clear-history.c,v 1.8 2011/01/04 00:42:46 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -28,23 +28,22 @@ int cmd_clear_history_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_clear_history_entry = {
"clear-history", "clearhist",
+ "t:", 0, 0,
CMD_TARGET_PANE_USAGE,
- 0, "",
- cmd_target_init,
- cmd_target_parse,
- cmd_clear_history_exec,
- cmd_target_free,
- cmd_target_print
+ 0,
+ NULL,
+ NULL,
+ cmd_clear_history_exec
};
int
cmd_clear_history_exec(struct cmd *self, struct cmd_ctx *ctx)
{
- struct cmd_target_data *data = self->data;
+ struct args *args = self->args;
struct window_pane *wp;
struct grid *gd;
- if (cmd_find_pane(ctx, data->target, NULL, &wp) == NULL)
+ if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
return (-1);
gd = wp->base.grid;