cmd_{bfin,set}: add sub-command completions only when earlier tokens indicate that it makes sense to

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1933 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Mike Frysinger 14 years ago
parent b4730561a1
commit 1ddde8e7ec

@ -34,6 +34,9 @@
* src/cmd/cmd_bfin.c, src/cmd/cmd_cmd.c, src/cmd/cmd_debug.c,
src/cmd/cmd_print.c: Convert to new array helpers.
* src/cmd/cmd_bfin.c, src/cmd/cmd_set.c: Use new tokens arg to selectively
add matches for specific sub-commands.
2011-06-27 Jie Zhang <jie.zhang@analog.com>
* include/urjtag/Makefile.am (nodist_pkginclude_HEADERS): New and

@ -520,12 +520,37 @@ cmd_bfin_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
"emulation",
"reset",
};
static const char * const emu_cmds[] = {
"enable",
"trigger",
"enter",
"return",
"disable",
"exit",
"singlestep",
"status",
};
static const char * const reset_cmds[] = {
"core",
"system",
};
if (token_point != 1)
return;
urj_completion_mayben_add_matches (matches, match_cnt, text, text_len,
main_cmds);
switch (token_point)
{
case 1:
urj_completion_mayben_add_matches (matches, match_cnt, text, text_len,
main_cmds);
break;
case 2:
if (!strcmp (tokens[1], "reset"))
urj_completion_mayben_add_matches (matches, match_cnt, text,
text_len, reset_cmds);
else if (!strcmp (tokens[1], "emulation"))
urj_completion_mayben_add_matches (matches, match_cnt, text,
text_len, emu_cmds);
break;
}
}
const urj_cmd_t urj_cmd_bfin = {

@ -122,6 +122,13 @@ cmd_set_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
char * const *tokens, const char *text, size_t text_len,
size_t token_point)
{
static const char * const dir[] = {
"in", "out",
};
static const char * const data[] = {
"0", "1",
};
switch (token_point)
{
case 1:
@ -133,14 +140,14 @@ cmd_set_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
break;
case 3: /* direction */
urj_completion_mayben_add_match (matches, match_cnt, text, text_len, "in");
urj_completion_mayben_add_match (matches, match_cnt, text, text_len, "out");
urj_completion_mayben_add_matches (matches, match_cnt, text, text_len,
dir);
break;
case 4: /* value */
/* XXX: Only applies if token[1] == "out" ... */
urj_completion_mayben_add_match (matches, match_cnt, text, text_len, "0");
urj_completion_mayben_add_match (matches, match_cnt, text, text_len, "1");
if (!strcmp (tokens[3], "out"))
urj_completion_mayben_add_matches (matches, match_cnt, text,
text_len, data);
break;
}
}

Loading…
Cancel
Save