summaryrefslogtreecommitdiff
path: root/command.c
diff options
context:
space:
mode:
authorWilliam Casarin <jb55@jb55.com>2018-07-09 18:49:53 -0700
committerWilliam Casarin <jb55@jb55.com>2018-07-09 18:49:53 -0700
commit7e47f1cea16741008c626fb39a1d6298064608cf (patch)
tree7f57a77bf362cf35f14f31c86ca1c5e2b3039c5a /command.c
parent1ee2efb9667af35d5e5ccfea6824701c2fdbce44 (diff)
move example commands to cfg.def.h
Diffstat (limited to 'command.c')
-rw-r--r--command.c37
1 files changed, 8 insertions, 29 deletions
diff --git a/command.c b/command.c
index de1ec97..bf9003f 100644
--- a/command.c
+++ b/command.c
@@ -40,39 +40,18 @@ command_lookup(struct command *cmd, int ncmds, const char *binding) {
/* { .bind = "d", .name = "emacs-dev", .nchildren = 0, .children = NULL }, */
/* }; */
-static struct command browser_commands[] = {
- { .bind = "s", .name = "chrome", .nchildren = 0, .children = NULL },
- { .bind = "c", .name = "chromium", .nchildren = 0, .children = NULL },
- { .bind = "f", .name = "firefox", .nchildren = 0, .children = NULL },
-};
-
-static const struct command examples[] = {
- { .bind = "b",
- .name = "browsers",
- .nchildren = LENGTH(browser_commands),
- .children = browser_commands
- },
-
- { .bind = "e",
- .name = "emacs-dev",
- .children = NULL,
- .nchildren = 0
- },
-};
-
struct command *
-test_root_commands(tal_t *ctx, int *ncmds) {
- unsigned long i;
+test_root_commands(tal_t *ctx, const struct command *commands, int ncmds) {
+ int i;
struct command *cmds = NULL;
- cmds = tal_arr(ctx, struct command, LENGTH(examples));
- *ncmds = LENGTH(examples);
+ cmds = tal_arr(ctx, struct command, ncmds);
- for (i = 0; i < LENGTH(examples); ++i) {
- cmds[i].children = examples[i].children;
- cmds[i].name = examples[i].name;
- cmds[i].bind = examples[i].bind;
- cmds[i].nchildren = examples[i].nchildren;
+ for (i = 0; i < ncmds; ++i) {
+ cmds[i].children = commands[i].children;
+ cmds[i].name = commands[i].name;
+ cmds[i].bind = commands[i].bind;
+ cmds[i].nchildren = commands[i].nchildren;
}
return cmds;