1.msh默认输出接口修改。
This commit is contained in:
@@ -43,7 +43,7 @@ static void msh_refresh_line(void)
|
||||
#ifndef MR_CFG_MSH_PROMPT
|
||||
#define MR_CFG_MSH_PROMPT "msh>"
|
||||
#endif /* MR_CFG_MSH_PROMPT */
|
||||
mr_printf(MR_CFG_MSH_PROMPT" ");
|
||||
mr_msh_printf(MR_CFG_MSH_PROMPT" ");
|
||||
}
|
||||
msh.cursor = 0;
|
||||
msh.bytes = 0;
|
||||
@@ -58,7 +58,7 @@ static void msh_new_line(void)
|
||||
#ifndef MR_CFG_MSH_PROMPT
|
||||
#define MR_CFG_MSH_PROMPT "msh>"
|
||||
#endif /* MR_CFG_MSH_PROMPT */
|
||||
mr_printf("\r\n"MR_CFG_MSH_PROMPT" ");
|
||||
mr_msh_printf("\r\n"MR_CFG_MSH_PROMPT" ");
|
||||
}
|
||||
msh.cursor = 0;
|
||||
msh.bytes = 0;
|
||||
@@ -70,7 +70,7 @@ static void msh_move_cursor_left(void)
|
||||
if (msh.cursor > 0)
|
||||
{
|
||||
msh.cursor--;
|
||||
mr_printf(MSH_CURSOR_FORWARD(1));
|
||||
mr_msh_printf(MSH_CURSOR_FORWARD(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ static void msh_move_cursor_right(void)
|
||||
if (msh.cursor < msh.bytes)
|
||||
{
|
||||
msh.cursor++;
|
||||
mr_printf(MSH_CURSOR_BACKWARD(1));
|
||||
mr_msh_printf(MSH_CURSOR_BACKWARD(1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ static void msh_delete_char(void)
|
||||
if (msh.cursor > 0)
|
||||
{
|
||||
/* Move the cursor forward and delete the character */
|
||||
mr_printf(MSH_CURSOR_FORWARD(1)MSH_DELETE_CHAR(1));
|
||||
mr_msh_printf(MSH_CURSOR_FORWARD(1)MSH_DELETE_CHAR(1));
|
||||
|
||||
/* Check if you need to remove characters from the middle */
|
||||
if (msh.cursor != msh.bytes)
|
||||
@@ -119,7 +119,7 @@ static void msh_insert_char(char c)
|
||||
} else
|
||||
{
|
||||
/* Insert the character */
|
||||
mr_printf(MSH_INSERT_CHAR(1));
|
||||
mr_msh_printf(MSH_INSERT_CHAR(1));
|
||||
|
||||
/* Readjust string */
|
||||
for (size_t i = msh.cursor; i < msh.bytes; i++)
|
||||
@@ -135,7 +135,7 @@ static void msh_insert_char(char c)
|
||||
/* Echo the character */
|
||||
if (msh.echo == MR_ENABLE)
|
||||
{
|
||||
mr_printf("%c", c);
|
||||
mr_msh_printf("%c", c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ static int msh_parse_cmd(void)
|
||||
old_arg = arg;
|
||||
}
|
||||
|
||||
mr_printf("\r\n");
|
||||
mr_msh_printf("\r\n");
|
||||
msh_cmd->call(argc, argv);
|
||||
return MR_TRUE;
|
||||
}
|
||||
@@ -334,25 +334,25 @@ static int msh_cmd_help(int argc, void *argv)
|
||||
{
|
||||
for (const struct mr_msh_cmd *msh_cmd = ((&_mr_msh_cmd_start) + 1); msh_cmd < &_mr_msh_cmd_end; msh_cmd++)
|
||||
{
|
||||
mr_printf("%-*s - %s\r\n", MR_CFG_MSH_NAME_MAX, msh_cmd->name, msh_cmd->help);
|
||||
mr_msh_printf("%-*s - %s\r\n", MR_CFG_MSH_NAME_MAX, msh_cmd->name, msh_cmd->help);
|
||||
}
|
||||
return MR_EOK;
|
||||
}
|
||||
|
||||
static int msh_cmd_clear(int argc, void *argv)
|
||||
{
|
||||
mr_printf(MSH_CLEAR);
|
||||
mr_msh_printf(MSH_CLEAR);
|
||||
return MR_EOK;
|
||||
}
|
||||
|
||||
static int msh_cmd_logo(int argc, void *argv)
|
||||
{
|
||||
mr_printf(" __ __ _ _ _ \r\n");
|
||||
mr_printf("| \\/ | _ __ | | (_) | |__ _ __ __ _ _ __ _ _\r\n");
|
||||
mr_printf("| |\\/| | | '__| _____ | | | | | '_ \\ | '__| / _` | | '__| | | | |\r\n");
|
||||
mr_printf("| | | | | | |_____| | | | | | |_) | | | | (_| | | | | |_| |\r\n");
|
||||
mr_printf("|_| |_| |_| |_| |_| |_.__/ |_| \\__,_| |_| \\__, |\r\n");
|
||||
mr_printf(" |___/\r\n");
|
||||
mr_msh_printf(" __ __ _ _ _ \r\n");
|
||||
mr_msh_printf("| \\/ | _ __ | | (_) | |__ _ __ __ _ _ __ _ _\r\n");
|
||||
mr_msh_printf("| |\\/| | | '__| _____ | | | | | '_ \\ | '__| / _` | | '__| | | | |\r\n");
|
||||
mr_msh_printf("| | | | | | |_____| | | | | | |_) | | | | (_| | | | | |_| |\r\n");
|
||||
mr_msh_printf("|_| |_| |_| |_| |_| |_.__/ |_| \\__,_| |_| \\__, |\r\n");
|
||||
mr_msh_printf(" |___/\r\n");
|
||||
return MR_EOK;
|
||||
}
|
||||
|
||||
@@ -384,7 +384,7 @@ int mr_msh_init(void)
|
||||
msh.echo = MR_ENABLE;
|
||||
#endif /* MR_USING_MSH_ECHO */
|
||||
/* Print the prompt */
|
||||
mr_printf(MSH_CLEAR);
|
||||
mr_msh_printf(MSH_CLEAR);
|
||||
msh_refresh_line();
|
||||
return MR_EOK;
|
||||
}
|
||||
|
||||
@@ -59,6 +59,14 @@ struct mr_msh_cmd
|
||||
#define MR_MSH_GET_ARG(index) \
|
||||
(((index) < (argc)) ? (((const char **)(argv))[index]) : MR_NULL)
|
||||
|
||||
/**
|
||||
* @brief This macro function prints a formatted string.
|
||||
*
|
||||
* @param fmt The format string.
|
||||
* @param ... The arguments.
|
||||
*/
|
||||
#define mr_msh_printf(fmt, ...) mr_printf(fmt, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* @addtogroup Msh.
|
||||
* @{
|
||||
@@ -68,6 +76,7 @@ void mr_msh_recv_char(char c);
|
||||
#else
|
||||
#define MR_MSH_EXPORT(name, fn, help, level)
|
||||
#define MR_MSH_CMD_EXPORT(name, fn, help)
|
||||
#define mr_msh_printf(...)
|
||||
#endif /* MR_USING_MSH */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -789,19 +789,19 @@ static void msh_list_tree(struct mr_dev *parent, int level)
|
||||
{
|
||||
if (level == 0)
|
||||
{
|
||||
mr_printf("|-- %-*s", MR_CFG_DEV_NAME_MAX, parent->name);
|
||||
mr_msh_printf("|-- %-*s", MR_CFG_DEV_NAME_MAX, parent->name);
|
||||
} else
|
||||
{
|
||||
mr_printf("%*s|-- %-*s", level, " ", MR_CFG_DEV_NAME_MAX, parent->name);
|
||||
mr_msh_printf("%*s|-- %-*s", level, " ", MR_CFG_DEV_NAME_MAX, parent->name);
|
||||
}
|
||||
for (size_t i = 0; i < MR_CFG_DESC_MAX; i++)
|
||||
{
|
||||
if (desc_map[i].dev == parent)
|
||||
{
|
||||
mr_printf(" [%d]", i);
|
||||
mr_msh_printf(" [%d]", i);
|
||||
}
|
||||
}
|
||||
mr_printf("\r\n");
|
||||
mr_msh_printf("\r\n");
|
||||
for (struct mr_list *child = parent->clist.next; child != &parent->clist; child = child->next)
|
||||
{
|
||||
struct mr_dev *dev = MR_CONTAINER_OF(child, struct mr_dev, list);
|
||||
|
||||
Reference in New Issue
Block a user