hide some completion structures
[protos/libecoli.git] / examples / readline / main.c
index 2c81c53..6095808 100644 (file)
@@ -15,7 +15,7 @@
 #include <ecoli_node.h>
 #include <ecoli_parse.h>
 #include <ecoli_complete.h>
-#include <ecoli_keyval.h>
+#include <ecoli_dict.h>
 #include <ecoli_node_str.h>
 #include <ecoli_node_seq.h>
 #include <ecoli_node_space.h>
@@ -70,7 +70,7 @@ static char *my_completion_entry(const char *s, int state)
                return NULL;
 
        item_str = ec_comp_item_get_str(item);
-       if (c->count_full == 1) {
+       if (ec_comp_count(c, EC_COMP_FULL) == 1) {
 
                /* don't add the trailing space for partial completions */
                if (state == 0) {
@@ -113,12 +113,11 @@ static char *get_node_help(const struct ec_comp_item *item)
        const char *node_desc = NULL;
 
        grp = ec_comp_item_get_grp(item);
-       state = grp->state;
-       for (state = grp->state; state != NULL;
+       for (state = ec_comp_group_get_state(grp); state != NULL;
             state = ec_parse_get_parent(state)) {
                node = ec_parse_get_node(state);
                if (node_help == NULL)
-                       node_help = ec_keyval_get(ec_node_attrs(node), "help");
+                       node_help = ec_dict_get(ec_node_attrs(node), "help");
                if (node_desc == NULL)
                        node_desc = ec_node_desc(node);
        }
@@ -244,13 +243,13 @@ static int create_commands(void)
        );
        if (cmd == NULL)
                goto fail;
-       ec_keyval_set(ec_node_attrs(cmd), "help",
+       ec_dict_set(ec_node_attrs(cmd), "help",
                "say hello to someone several times", NULL);
-       ec_keyval_set(ec_node_attrs(ec_node_find(cmd, "john")),
+       ec_dict_set(ec_node_attrs(ec_node_find(cmd, "john")),
                "help", "specific help for john", NULL);
-       ec_keyval_set(ec_node_attrs(ec_node_find(cmd, "name")),
+       ec_dict_set(ec_node_attrs(ec_node_find(cmd, "name")),
                "help", "the name of the person", NULL);
-       ec_keyval_set(ec_node_attrs(ec_node_find(cmd, "int")),
+       ec_dict_set(ec_node_attrs(ec_node_find(cmd, "int")),
                "help", "an integer (0-10)", NULL);
        if (ec_node_or_add(cmdlist, cmd) < 0)
                goto fail;
@@ -261,11 +260,11 @@ static int create_commands(void)
                        ec_node_int("count", 0, 10, 10));
        if (cmd == NULL)
                goto fail;
-       ec_keyval_set(ec_node_attrs(cmd), "help",
+       ec_dict_set(ec_node_attrs(cmd), "help",
                "say good morning to someone several times", NULL);
-       ec_keyval_set(ec_node_attrs(ec_node_find(cmd, "name")), "help",
+       ec_dict_set(ec_node_attrs(ec_node_find(cmd, "name")), "help",
                "the person to greet", NULL);
-       ec_keyval_set(ec_node_attrs(ec_node_find(cmd, "count")), "help",
+       ec_dict_set(ec_node_attrs(ec_node_find(cmd, "count")), "help",
                "how many times to greet (0-10)", NULL);
        if (ec_node_or_add(cmdlist, cmd) < 0)
                goto fail;
@@ -275,7 +274,7 @@ static int create_commands(void)
                        "buy potatoes,carrots,pumpkins");
        if (cmd == NULL)
                goto fail;
-       ec_keyval_set(ec_node_attrs(cmd), "help",
+       ec_dict_set(ec_node_attrs(cmd), "help",
                "buy some vegetables", NULL);
        if (ec_node_or_add(cmdlist, cmd) < 0)
                goto fail;
@@ -292,7 +291,7 @@ static int create_commands(void)
                        1, 0));
        if (cmd == NULL)
                goto fail;
-       ec_keyval_set(ec_node_attrs(cmd), "help",
+       ec_dict_set(ec_node_attrs(cmd), "help",
                "eat vegetables (take some more potatoes)", NULL);
        if (ec_node_or_add(cmdlist, cmd) < 0)
                goto fail;
@@ -301,7 +300,7 @@ static int create_commands(void)
        cmd = EC_NODE_SEQ(EC_NO_ID,
                ec_node_str(EC_NO_ID, "bye")
        );
-       ec_keyval_set(ec_node_attrs(cmd), "help", "say bye", NULL);
+       ec_dict_set(ec_node_attrs(cmd), "help", "say bye", NULL);
        if (ec_node_or_add(cmdlist, cmd) < 0)
                goto fail;
 
@@ -310,7 +309,7 @@ static int create_commands(void)
                ec_node_str(EC_NO_ID, "load"),
                ec_node("file", EC_NO_ID)
        );
-       ec_keyval_set(ec_node_attrs(cmd), "help", "load a file", NULL);
+       ec_dict_set(ec_node_attrs(cmd), "help", "load a file", NULL);
        if (ec_node_or_add(cmdlist, cmd) < 0)
                goto fail;