summaryrefslogtreecommitdiffstats
path: root/cmd-list-keys.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2011-01-07 14:45:34 +0000
committerTiago Cunha <tcunha@gmx.com>2011-01-07 14:45:34 +0000
commit1df427bc7b1a458f4d3fe6f9255010708a8d8634 (patch)
tree6d47a72a426bb3e18146c682591d398607a8a211 /cmd-list-keys.c
parent219442cff707a1febb6a75ba2cfe48b02ae0a22e (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-list-keys.c')
-rw-r--r--cmd-list-keys.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/cmd-list-keys.c b/cmd-list-keys.c
index 82cc24f8..3aab14ee 100644
--- a/cmd-list-keys.c
+++ b/cmd-list-keys.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-list-keys.c,v 1.25 2010-10-24 01:31:57 tcunha Exp $ */
+/* $Id: cmd-list-keys.c,v 1.26 2011-01-07 14:45:34 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -32,26 +32,25 @@ int cmd_list_keys_table(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_list_keys_entry = {
"list-keys", "lsk",
+ "t:", 0, 0,
"[-t key-table]",
- 0, "",
- cmd_target_init,
- cmd_target_parse,
- cmd_list_keys_exec,
- cmd_target_free,
- cmd_target_print
+ 0,
+ NULL,
+ NULL,
+ cmd_list_keys_exec
};
int
cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
{
- struct cmd_target_data *data = self->data;
+ struct args *args = self->args;
struct key_binding *bd;
const char *key;
char tmp[BUFSIZ];
size_t used;
int width, keywidth;
- if (data->target != NULL)
+ if (args_has(args, 't'))
return (cmd_list_keys_table(self, ctx));
width = 0;
@@ -95,14 +94,16 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
int
cmd_list_keys_table(struct cmd *self, struct cmd_ctx *ctx)
{
- struct cmd_target_data *data = self->data;
+ struct args *args = self->args;
+ const char *tablename;
const struct mode_key_table *mtab;
struct mode_key_binding *mbind;
const char *key, *cmdstr, *mode;
int width, keywidth;
- if ((mtab = mode_key_findtable(data->target)) == NULL) {
- ctx->error(ctx, "unknown key table: %s", data->target);
+ tablename = args_get(args, 't');
+ if ((mtab = mode_key_findtable(tablename)) == NULL) {
+ ctx->error(ctx, "unknown key table: %s", tablename);
return (-1);
}