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) {
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)
};
struct ec_comp_item;
-
-TAILQ_HEAD(ec_comp_item_list, ec_comp_item);
-
-struct ec_comp_group {
- TAILQ_ENTRY(ec_comp_group) next;
- const struct ec_node *node;
- struct ec_comp_item_list items;
- struct ec_parse *state;
- struct ec_dict *attrs;
-};
-
-TAILQ_HEAD(ec_comp_group_list, ec_comp_group);
-
-struct ec_comp {
- unsigned count;
- unsigned count_full;
- unsigned count_partial;
- unsigned count_unknown;
- struct ec_parse *cur_state;
- struct ec_comp_group *cur_group;
- struct ec_comp_group_list groups;
- struct ec_dict *attrs;
-};
+struct ec_comp_group;
+struct ec_comp;
/*
* return a comp object filled with items
int ec_comp_merge(struct ec_comp *to,
struct ec_comp *from);
-struct ec_parse *ec_comp_get_state(struct ec_comp *comp);
+/**
+ * Get current completion state.
+ *
+ */
+struct ec_parse *ec_comp_get_state(const struct ec_comp *comp);
+
+/**
+ * Get current completion group.
+ *
+ */
+struct ec_comp_group *ec_comp_get_group(const struct ec_comp *comp);
+
+/**
+ * Get completion group attributes.
+ *
+ */
+struct ec_dict *ec_comp_get_attrs(const struct ec_comp *comp);
/* shortcut for ec_comp_item() + ec_comp_item_add() */
int ec_comp_add_item(struct ec_comp *comp,
int ec_comp_item_set_completion(struct ec_comp_item *item,
const char *completion);
+/**
+ * Get the completion group node.
+ *
+ *
+ */
+const struct ec_node *
+ec_comp_group_get_node(const struct ec_comp_group *grp);
+
+/**
+ * Get the completion group parsed state.
+ *
+ *
+ */
+const struct ec_parse *
+ec_comp_group_get_state(const struct ec_comp_group *grp);
+
+/**
+ * Get the completion group attributes.
+ *
+ *
+ */
+const struct ec_dict *
+ec_comp_group_get_attrs(const struct ec_comp_group *grp);
+
+
/**
*
*
struct ec_dict *attrs;
};
+TAILQ_HEAD(ec_comp_item_list, ec_comp_item);
+
+struct ec_comp_group {
+ TAILQ_ENTRY(ec_comp_group) next;
+ const struct ec_node *node;
+ struct ec_comp_item_list items;
+ struct ec_parse *state;
+ struct ec_dict *attrs;
+};
+
+TAILQ_HEAD(ec_comp_group_list, ec_comp_group);
+
+struct ec_comp {
+ unsigned count;
+ unsigned count_full;
+ unsigned count_partial;
+ unsigned count_unknown;
+ struct ec_parse *cur_state;
+ struct ec_comp_group *cur_group;
+ struct ec_comp_group_list groups;
+ struct ec_dict *attrs;
+};
+
struct ec_comp *ec_comp(struct ec_parse *state)
{
struct ec_comp *comp = NULL;
return NULL;
}
-struct ec_parse *ec_comp_get_state(struct ec_comp *comp)
+struct ec_parse *ec_comp_get_state(const struct ec_comp *comp)
{
return comp->cur_state;
}
+struct ec_comp_group *ec_comp_get_group(const struct ec_comp *comp)
+{
+ return comp->cur_group;
+}
+
+struct ec_dict *ec_comp_get_attrs(const struct ec_comp *comp)
+{
+ return comp->attrs;
+}
+
int
ec_node_complete_child(const struct ec_node *node,
struct ec_comp *comp,
ec_free(grp);
}
+const struct ec_node *
+ec_comp_group_get_node(const struct ec_comp_group *grp)
+{
+ return grp->node;
+}
+
+const struct ec_parse *
+ec_comp_group_get_state(const struct ec_comp_group *grp)
+{
+ return grp->state;
+}
+
+const struct ec_dict *
+ec_comp_group_get_attrs(const struct ec_comp_group *grp)
+{
+ return grp->attrs;
+}
+
void ec_comp_free(struct ec_comp *comp)
{
struct ec_comp_group *grp;
grp = ec_comp_item_get_grp(item);
- 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)
/* add the node pointer in the attributes, so it will be freed
* when parse is freed */
snprintf(key, sizeof(key), "_dyn_%p", child);
- ret = ec_dict_set(comp->attrs, key, child,
+ ret = ec_dict_set(ec_comp_get_attrs(comp), key, child,
(void *)node_free);
if (ret < 0) {
child = NULL; /* already freed */