return NULL;
ec_completed_iter_free(iter);
- iter = ec_completed_iter(c, EC_MATCH | EC_PARTIAL_MATCH);
+ iter = ec_completed_iter(c, EC_COMP_FULL | EC_PARTIAL_MATCH);
if (iter == NULL)
return NULL;
}
/* don't add the trailing space for partial completions */
if (state == 0) {
item_type = ec_completed_item_get_type(item);
- if (item_type == EC_MATCH)
+ if (item_type == EC_COMP_FULL)
rl_completion_suppress_append = 0;
else
rl_completion_suppress_append = 1;
/* this function builds the help string */
static char *get_node_help(const struct ec_completed_item *item)
{
+ const struct ec_completed_group *grp;
+ struct ec_parsed *state; // XXX keep const with macro
const struct ec_node *node;
char *help = NULL;
const char *node_help = NULL;
// size_t i;
(void)item;
-#if 0 //XXX
- /* Retrieve the most precise help for this node. */
- for (i = 0; i < item->pathlen; i++) {
- node = item->path[i];
+#if 1
+ grp = ec_completed_item_get_grp(item);
+ state = grp->state;
+ for (state = grp->state; state != NULL;
+ state = ec_parsed_get_parent(state)) {
+ node = ec_parsed_get_node(state);
if (node_help == NULL)
node_help = ec_keyval_get(ec_node_attrs(node), "help");
if (node_desc == NULL)
static int show_help(int ignore, int invoking_key)
{
struct ec_completed_iter *iter;
+ const struct ec_completed_group *grp, *prev_grp = NULL;
const struct ec_completed_item *item;
- const struct ec_node *prev_node = NULL;
struct ec_completed *c;
struct ec_parsed *p;
char *line = NULL;
/* let's display one contextual help per node */
count = 0;
- iter = ec_completed_iter(c, EC_NO_MATCH | EC_MATCH | EC_PARTIAL_MATCH);
+ iter = ec_completed_iter(c,
+ EC_COMP_UNKNOWN | EC_COMP_FULL | EC_PARTIAL_MATCH);
if (iter == NULL)
goto fail;
helps[1] = "<return>";
while ((item = ec_completed_iter_next(iter)) != NULL) {
- const struct ec_node *node;
char **tmp;
- /* keep one help per node, skip other items */
- node = ec_completed_item_get_node(item);
- if (node == prev_node)
+ /* keep one help per group, skip other items */
+ grp = ec_completed_item_get_grp(item);
+ if (grp == prev_grp)
continue;
+ prev_grp = grp;
+
tmp = realloc(helps, (count + match + 2) * sizeof(char *));
if (tmp == NULL)
goto fail;