cmd_cable: add support for sub-cable parameters by generalizing the new initbus code

git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1945 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Mike Frysinger 14 years ago
parent 35a70b6804
commit a16e5c82ed

@ -9,6 +9,13 @@
* src/tap/chain.c (urj_tap_chain_connect): Replace look up code with new
urj_tap_cable_find helper.
* src/cmd/cmd.h, src/cmd/cmd_cmd.c (urj_completion_mayben_add_param_list):
Add new helper which automatically adds urj_param_list_t for matches.
* src/cmd/cmd_cable.c (cmd_cable_complete): Use new helper to add cable
options to possible matches.
* cmd/cmd_initbus.c (cmd_initbus_complete): Use new helper rather than
adding parameters ourselves.
2011-06-30 Jie Zhang <jie.zhang@analog.com>
* src/cmd/Makefile.am (generated_cmd_list.h): Depend on

@ -37,6 +37,7 @@
#include <stdlib.h> /* qsort */
#include <sysdep.h>
#include <urjtag/params.h>
#include <urjtag/types.h>
typedef struct
@ -134,6 +135,18 @@ void urj_completion_mayben_add_matches_num (char ***matches, size_t *cnt,
urj_completion_mayben_add_matches_num (matches, cnt, text, text_len, \
matchs, ARRAY_SIZE (matchs))
/**
* This is just like urj_completion_mayben_add_matches_num, but the array
* info comes straight from the urj_param_list_t structure.
*
* @param text the string to compare to match (e.g. user input)
* @param text_len the length of text
* @param param_list the list of parameter strings to possibly add to the set of matches
*/
void urj_completion_mayben_add_param_list (char ***matches, size_t *cnt,
const char *text, size_t text_len,
urj_param_list_t param_list);
/**
* Internal completion helper for matching against the signal list.
* Since many functions involve signals as an option, unify the code

@ -149,8 +149,9 @@ cmd_cable_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
urj_tap_cable_drivers[i]->name);
break;
case 2:
/* XXX: in the future, we want to complete cable options too */
urj_completion_mayben_add_match (matches, match_cnt, text, text_len, "help");
urj_completion_mayben_add_param_list (matches, match_cnt, text,
text_len, urj_cable_param_list);
break;
}
}

@ -99,6 +99,18 @@ urj_completion_mayben_add_matches_num (char ***matches, size_t *cnt,
matchs[n]);
}
void
urj_completion_mayben_add_param_list (char ***matches, size_t *cnt,
const char *text, size_t text_len,
urj_param_list_t param_list)
{
size_t i;
for (i = 0; i < param_list.n; ++i)
urj_completion_mayben_add_match (matches, cnt, text, text_len,
param_list.list[i].string);
}
void
urj_completion_maybe_add_match (char ***matches, size_t *cnt, const char *text,
const char *match)

@ -80,9 +80,8 @@ cmd_initbus_complete (urj_chain_t *chain, char ***matches, size_t *match_cnt,
urj_bus_drivers[i]->name);
break;
default:
for (i = 0; i < urj_bus_param_list.n; ++i)
urj_completion_mayben_add_match (matches, match_cnt, text, text_len,
urj_bus_param_list.list[i].string);
urj_completion_mayben_add_param_list (matches, match_cnt, text,
text_len, urj_bus_param_list);
break;
}
}

Loading…
Cancel
Save