[shell] add finsh_get/set_prompt_mode.
This commit is contained in:
parent
1d588c7475
commit
85e732ddaf
@ -67,6 +67,13 @@ const char *finsh_get_prompt()
|
|||||||
#define _PROMPT "finsh "
|
#define _PROMPT "finsh "
|
||||||
static char finsh_prompt[RT_CONSOLEBUF_SIZE + 1] = {0};
|
static char finsh_prompt[RT_CONSOLEBUF_SIZE + 1] = {0};
|
||||||
|
|
||||||
|
/* check prompt mode */
|
||||||
|
if (!shell->prompt_mode)
|
||||||
|
{
|
||||||
|
finsh_prompt[0] = '\0';
|
||||||
|
return finsh_prompt;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef FINSH_USING_MSH
|
#ifdef FINSH_USING_MSH
|
||||||
if (msh_is_used()) strcpy(finsh_prompt, _MSH_PROMPT);
|
if (msh_is_used()) strcpy(finsh_prompt, _MSH_PROMPT);
|
||||||
else
|
else
|
||||||
@ -84,6 +91,34 @@ const char *finsh_get_prompt()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup finsh
|
||||||
|
*
|
||||||
|
* This function get the prompt mode of finsh shell.
|
||||||
|
*
|
||||||
|
* @return prompt the prompt mode, 0 disable prompt mode, other values enable prompt mode.
|
||||||
|
*/
|
||||||
|
rt_uint32_t finsh_get_prompt_mode(void)
|
||||||
|
{
|
||||||
|
RT_ASSERT(shell != RT_NULL);
|
||||||
|
return shell->prompt_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup finsh
|
||||||
|
*
|
||||||
|
* This function set the prompt mode of finsh shell.
|
||||||
|
*
|
||||||
|
* The parameter 0 disable prompt mode, other values enable prompt mode.
|
||||||
|
*
|
||||||
|
* @param prompt the prompt mode
|
||||||
|
*/
|
||||||
|
void finsh_set_prompt_mode(rt_uint32_t prompt_mode)
|
||||||
|
{
|
||||||
|
RT_ASSERT(shell != RT_NULL);
|
||||||
|
shell->prompt_mode = prompt_mode;
|
||||||
|
}
|
||||||
|
|
||||||
static char finsh_getchar(void)
|
static char finsh_getchar(void)
|
||||||
{
|
{
|
||||||
#ifdef RT_USING_POSIX
|
#ifdef RT_USING_POSIX
|
||||||
|
@ -86,6 +86,7 @@ struct finsh_shell
|
|||||||
enum input_stat stat;
|
enum input_stat stat;
|
||||||
|
|
||||||
rt_uint8_t echo_mode:1;
|
rt_uint8_t echo_mode:1;
|
||||||
|
rt_uint8_t prompt_mode: 1;
|
||||||
|
|
||||||
#ifdef FINSH_USING_HISTORY
|
#ifdef FINSH_USING_HISTORY
|
||||||
rt_uint16_t current_history;
|
rt_uint16_t current_history;
|
||||||
@ -118,6 +119,9 @@ int finsh_system_init(void);
|
|||||||
void finsh_set_device(const char* device_name);
|
void finsh_set_device(const char* device_name);
|
||||||
const char* finsh_get_device(void);
|
const char* finsh_get_device(void);
|
||||||
|
|
||||||
|
rt_uint32_t finsh_get_prompt_mode(void);
|
||||||
|
void finsh_set_prompt_mode(rt_uint32_t prompt_mode);
|
||||||
|
|
||||||
#ifdef FINSH_USING_AUTH
|
#ifdef FINSH_USING_AUTH
|
||||||
rt_err_t finsh_set_password(const char *password);
|
rt_err_t finsh_set_password(const char *password);
|
||||||
const char *finsh_get_password(void);
|
const char *finsh_get_password(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user