添加了xmcd prompt的颜色以及一些其他的小修改

This commit is contained in:
hqm 2021-10-11 21:50:24 +08:00
parent 7c8a4b2f85
commit afb1ef7a51
5 changed files with 27 additions and 18 deletions

View File

@ -1,7 +1,7 @@
/*
* @Author: your name
* @Date: 2021-09-22 22:33:17
* @LastEditTime: 2021-09-29 22:35:29
* @LastEditTime: 2021-10-11 13:41:50
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /xcmd/extensions/test/test.c
@ -53,15 +53,6 @@ static uint8_t param_check(int need, int argc, char*argv[])
return ret;
}
static int cmd_echo(int argc, char* argv[])
{
if(param_check(1, argc, argv))
{
xcmd_print("%s\r\n", argv[1]);
}
return 0;
}
static int cmd_example(int argc, char* argv[])
{
uint8_t i;
@ -180,7 +171,6 @@ static int cmd_print_color(int argc, char* argv[])
static xcmd_t cmds[] =
{
{"echo", cmd_echo, "echo [msg]", NULL},
{"history", cmd_history, "show history list", NULL},
{"example", cmd_example, "example [-f|-i|-s] [val]", NULL},
{"delcmd", cmd_delete_cmd, "delete cmd [val]", NULL},

View File

@ -1,7 +1,7 @@
/*
* @Author: your name
* @Date: 2021-09-17 23:03:06
* @LastEditTime: 2021-10-08 21:52:29
* @LastEditTime: 2021-10-11 21:40:01
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /xcmd/inc/xcmd_confg.h
@ -36,6 +36,14 @@ extern "C" {
#define XCMD_PRINT_BUF_MAX_LENGTH (XCMD_LINE_MAX_LENGTH+32) /* xcmd_print缓存 */
#endif
#ifndef XCMD_DEFAULT_PROMPT
#define XCMD_DEFAULT_PROMPT ("->")
#endif
#ifndef XCMD_DEFAULT_PROMPT_CLOLR
#define XCMD_DEFAULT_PROMPT_CLOLR TX_GREEN
#endif
#ifdef __cplusplus
}
#endif

View File

@ -359,7 +359,11 @@ void xcmd_display_clear(void)
{
char *line = xcmd_display_get();
xcmd_print(DL(0));
xcmd_print("\r%s", g_xcmder.parser.prompt);
#ifndef XCMD_DEFAULT_PROMPT_CLOLR
xcmd_print("%s", xcmd_get_prompt());
#else
xcmd_print(XCMD_DEFAULT_PROMPT_CLOLR "%s" TX_DEF, xcmd_get_prompt());
#endif
g_xcmder.parser.byte_num = 0;
g_xcmder.parser.cursor = 0;
line[0] = '\0';
@ -418,7 +422,7 @@ void xcmd_display_cursor_set(uint16_t pos)
pos = g_xcmder.parser.byte_num;
}
g_xcmder.parser.cursor = pos;
xcmd_print(CHA(g_xcmder.parser.cursor+3));
xcmd_print(CHA(g_xcmder.parser.cursor+strlen(g_xcmder.parser.prompt)+1));
}
uint16_t xcmd_display_cursor_get(void)
@ -675,7 +679,7 @@ void xcmd_init( int (*get_c)(uint8_t*), int (*put_c)(uint8_t))
g_xcmder.io.get_c = get_c;
g_xcmder.io.put_c = put_c;
g_xcmder.parser.prompt = "->";
g_xcmder.parser.prompt = XCMD_DEFAULT_PROMPT;
g_xcmder.parser.byte_num = 0;
g_xcmder.parser.cursor = 0;
g_xcmder.parser.encode_case_stu = 0;

View File

@ -1,7 +1,7 @@
/*
* @Author: your name
* @Date: 2021-09-15 00:11:50
* @LastEditTime: 2021-09-17 23:06:51
* @LastEditTime: 2021-10-11 21:37:09
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /xcmd/src/xcmd_default_cmds.c

View File

@ -1,7 +1,7 @@
/*
* @Author: your name
* @Date: 2021-09-15 00:11:50
* @LastEditTime: 2021-09-29 22:00:26
* @LastEditTime: 2021-10-11 21:38:26
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: /xcmd/src/xcmd_default_keys.c
@ -38,7 +38,12 @@ static int xcmd_enter(void *pv)
xcmd_exec(cmd);
cmd[0] = '\0';
}
xcmd_print("%s", xcmd_get_prompt());
#ifndef XCMD_DEFAULT_PROMPT_CLOLR
xcmd_print("%s", xcmd_get_prompt());
#else
xcmd_print(XCMD_DEFAULT_PROMPT_CLOLR "%s" TX_DEF, xcmd_get_prompt());
#endif
return 0;
}
@ -61,6 +66,7 @@ static int xcmd_cursor_right(void *pv)
return 0;
}
#if XCMD_HISTORY_MAX_NUM
static int xcmd_history_dw(void *pv)
{
char *line = xcmd_history_prev();
@ -84,6 +90,7 @@ static int xcmd_history_up(void *pv)
}
return 0;
}
#endif
static int xcmd_auto_completion(void *pv)
{