mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-09 20:45:41 +08:00
add history and auto complete feature in finsh.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@54 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
1 parent
bd11f44ab4
commit
3da0559f23
2 files changed
+274
-12
No files matched your search
+106
@@ -369,6 +369,112 @@ int list()
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(list, list all symbol in system)
|
||||
|
||||
int str_is_prefix(const char* prefix, const char* str)
|
||||
{
|
||||
while ((*prefix) && (*prefix == *str))
|
||||
{
|
||||
prefix ++;
|
||||
str ++;
|
||||
}
|
||||
|
||||
if (*prefix == 0) return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void list_prefix(char* prefix)
|
||||
{
|
||||
struct finsh_syscall_item* syscall_item;
|
||||
struct finsh_sysvar_item* sysvar_item;
|
||||
rt_uint16_t func_cnt, var_cnt;
|
||||
const char* name_ptr;
|
||||
|
||||
func_cnt = 0;
|
||||
var_cnt = 0;
|
||||
{
|
||||
struct finsh_syscall* index;
|
||||
for (index = _syscall_table_begin; index < _syscall_table_end; index ++)
|
||||
{
|
||||
if (str_is_prefix(prefix, index->name) == 0)
|
||||
{
|
||||
if (func_cnt == 0)
|
||||
rt_kprintf("--function:\n");
|
||||
|
||||
func_cnt ++;
|
||||
/* set name_ptr */
|
||||
name_ptr = index->name;
|
||||
|
||||
#ifdef FINSH_USING_DESCRIPTION
|
||||
rt_kprintf("%-16s -- %s\n", index->name, index->desc);
|
||||
#else
|
||||
rt_kprintf("%s\n", index->name);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* list syscall list */
|
||||
syscall_item = global_syscall_list;
|
||||
while (syscall_item != NULL)
|
||||
{
|
||||
if (str_is_prefix(prefix, syscall_item->syscall.name) == 0)
|
||||
{
|
||||
if (func_cnt == 0)
|
||||
rt_kprintf("--function:\n");
|
||||
func_cnt ++;
|
||||
/* set name_ptr */
|
||||
name_ptr = syscall_item->syscall.name;
|
||||
|
||||
rt_kprintf("[l] %s\n", syscall_item->syscall.name);
|
||||
}
|
||||
syscall_item = syscall_item->next;
|
||||
}
|
||||
|
||||
{
|
||||
struct finsh_sysvar* index;
|
||||
for (index = _sysvar_table_begin; index < _sysvar_table_end; index ++)
|
||||
{
|
||||
if (str_is_prefix(prefix, index->name) == 0)
|
||||
{
|
||||
if (var_cnt == 0)
|
||||
rt_kprintf("--variable:\n");
|
||||
|
||||
var_cnt ++;
|
||||
/* set name ptr */
|
||||
name_ptr = index->name;
|
||||
|
||||
#ifdef FINSH_USING_DESCRIPTION
|
||||
rt_kprintf("%-16s -- %s\n", index->name, index->desc);
|
||||
#else
|
||||
rt_kprintf("%s\n", index->name);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sysvar_item = global_sysvar_list;
|
||||
while (sysvar_item != NULL)
|
||||
{
|
||||
if (str_is_prefix(prefix, sysvar_item->sysvar.name) == 0)
|
||||
{
|
||||
if (var_cnt == 0)
|
||||
rt_kprintf("--variable:\n");
|
||||
|
||||
var_cnt ++;
|
||||
/* set name ptr */
|
||||
name_ptr = sysvar_item->sysvar.name;
|
||||
|
||||
rt_kprintf("[l] %s\n", sysvar_item->sysvar.name);
|
||||
}
|
||||
sysvar_item = sysvar_item->next;
|
||||
}
|
||||
|
||||
/* only one matched */
|
||||
if ((func_cnt + var_cnt) == 1)
|
||||
{
|
||||
rt_strncpy(prefix, name_ptr, strlen(name_ptr));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FINSH_USING_SYMTAB
|
||||
static int dummy = 0;
|
||||
FINSH_VAR_EXPORT(dummy, finsh_type_int, dummy variable for finsh)
|
||||
|
||||
+168
-12
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user