From: EMC C. s. <cv...@cv...> - 2006-06-30 12:50:06
|
Modified file emc2/src/hal/utils/halcmd.c Full file: <http://cvs.linuxcnc.org/cvs/emc2/src/hal/utils/halcmd.c?rev=1.60> Difference: <http://cvs.linuxcnc.org/cvs/emc2/src/hal/utils/halcmd.c.diff?r1=1.59;r2=1.60> Branch: HEAD Log: revision 1.60 date: 2006/06/30 12:50:04; author: jepler; state: Exp; lines: +17 -3 complete -w and -iw for loadusr add vim turd --- halcmd.c 2006/06/29 21:17:07 1.59 +++ halcmd.c 2006/06/30 12:50:04 1.60 @@ -2969,6 +2969,8 @@ #ifdef HAVE_READLINE +static int argno; + static char *command_table[] = { "loadrt", "unloadrt", "loadusr", "lock", "unlock", "linkps", "linksp", "linkpp", "unlinkp", @@ -3210,16 +3212,27 @@ return strncmp(string, stem, strlen(stem)) == 0; } +char *loadusr_table[] = {"-w", "-iw", NULL}; + static char *loadusr_generator(const char *text, int state) { static int len; static DIR *d; struct dirent *ent; + static int doing_table; if(!state) { + if(argno == 1) doing_table = 1; + string_table = loadusr_table; len = strlen(text); d = opendir(EMC2_BIN_DIR); } + if(doing_table) { + char *result = table_generator(text, state); + if(result) return result; + doing_table = 0; + } + while(d && (ent = readdir(d))) { char *result; if(!startswith(ent->d_name, "hal")) continue; @@ -3260,8 +3273,6 @@ return isspace(ch) || ch == '=' || ch == '<' || ch == '>'; } -static int argno; - char **completer(const char *text, int start, int end) { int i; char **result = NULL; @@ -3355,7 +3366,7 @@ result = completion_matches_table(text, command_table); } else if(startswith(rl_line_buffer, "unloadrt ") && argno == 1) { result = rl_completion_matches(text, comp_generator); - } else if(startswith(rl_line_buffer, "loadusr ") && argno == 1) { + } else if(startswith(rl_line_buffer, "loadusr ") && argno < 3) { rtapi_mutex_give(&(hal_data->mutex)); // leaves rl_attempted_completion_over = 0 to complete from filesystem return rl_completion_matches(text, loadusr_generator); @@ -3400,3 +3411,6 @@ } return fgets(buf, bufsize, srcfile) != NULL; } + +/* vim:sts=4:sw=4:et + */ |