mirror of
https://github.com/NevermindZZT/letter-shell.git
synced 2025-01-21 10:02:54 +08:00
修复一个宏定义错误,优化shell结构体大小
This commit is contained in:
parent
3a0a5a493a
commit
5a6f200769
18
shell.c
18
shell.c
@ -129,9 +129,9 @@ void shellInit(SHELL_TypeDef *shell)
|
|||||||
shell->historyFlag = 0;
|
shell->historyFlag = 0;
|
||||||
shell->historyOffset = 0;
|
shell->historyOffset = 0;
|
||||||
shell->status.inputMode = SHELL_IN_NORMAL;
|
shell->status.inputMode = SHELL_IN_NORMAL;
|
||||||
|
shell->status.isActive = 0;
|
||||||
shell->status.tabFlag = 0;
|
shell->status.tabFlag = 0;
|
||||||
shell->command = SHELL_DEFAULT_COMMAND;
|
shell->command = SHELL_DEFAULT_COMMAND;
|
||||||
shell->isActive = 0;
|
|
||||||
shellAdd(shell);
|
shellAdd(shell);
|
||||||
|
|
||||||
#if SHELL_USING_AUTH == 1
|
#if SHELL_USING_AUTH == 1
|
||||||
@ -280,7 +280,7 @@ SHELL_TypeDef *shellGetCurrent(void)
|
|||||||
{
|
{
|
||||||
for (short i = 0; i < SHELL_MAX_NUMBER; i++)
|
for (short i = 0; i < SHELL_MAX_NUMBER; i++)
|
||||||
{
|
{
|
||||||
if (shellList[i] != NULL && shellList[i]->isActive == 1)
|
if (shellList[i] != NULL && shellList[i]->status.isActive == 1)
|
||||||
{
|
{
|
||||||
return shellList[i];
|
return shellList[i];
|
||||||
}
|
}
|
||||||
@ -664,9 +664,9 @@ static void shellEnter(SHELL_TypeDef *shell)
|
|||||||
base = shell->commandBase;
|
base = shell->commandBase;
|
||||||
if (strcmp((const char *)shell->param[0], "help") == 0)
|
if (strcmp((const char *)shell->param[0], "help") == 0)
|
||||||
{
|
{
|
||||||
shell->isActive = 1;
|
shell->status.isActive = 1;
|
||||||
shellHelp(paramCount, shell->param);
|
shellHelp(paramCount, shell->param);
|
||||||
shell->isActive = 0;
|
shell->status.isActive = 0;
|
||||||
shellDisplay(shell, shell->command);
|
shellDisplay(shell, shell->command);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -683,13 +683,13 @@ static void shellEnter(SHELL_TypeDef *shell)
|
|||||||
if (strcmp((const char *)shell->param[0], (base + i)->name) == 0)
|
if (strcmp((const char *)shell->param[0], (base + i)->name) == 0)
|
||||||
{
|
{
|
||||||
runFlag = 1;
|
runFlag = 1;
|
||||||
shell->isActive = 1;
|
shell->status.isActive = 1;
|
||||||
#if SHELL_AUTO_PRASE == 0
|
#if SHELL_AUTO_PRASE == 0
|
||||||
returnValue = (base + i)->function(paramCount, shell->param);
|
returnValue = (base + i)->function(paramCount, shell->param);
|
||||||
#else
|
#else
|
||||||
returnValue = shellExtRun((base + i)->function, paramCount, shell->param);
|
returnValue = shellExtRun((base + i)->function, paramCount, shell->param);
|
||||||
#endif /** SHELL_AUTO_PRASE == 0 */
|
#endif /** SHELL_AUTO_PRASE == 0 */
|
||||||
shell->isActive = 0;
|
shell->status.isActive = 0;
|
||||||
#if SHELL_DISPLAY_RETURN == 1
|
#if SHELL_DISPLAY_RETURN == 1
|
||||||
shellDisplayReturn(shell, returnValue);
|
shellDisplayReturn(shell, returnValue);
|
||||||
#endif /** SHELL_DISPLAY_RETURN == 1 */
|
#endif /** SHELL_DISPLAY_RETURN == 1 */
|
||||||
@ -815,9 +815,9 @@ static void shellTab(SHELL_TypeDef *shell)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
shell->isActive = 1;
|
shell->status.isActive = 1;
|
||||||
shellHelp(1, (void *)0);
|
shellHelp(1, (void *)0);
|
||||||
shell->isActive = 0;
|
shell->status.isActive = 0;
|
||||||
shellDisplay(shell, shell->command);
|
shellDisplay(shell, shell->command);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1222,7 +1222,7 @@ SHELL_EXPORT_CMD(vars, shellListVariables, show vars);
|
|||||||
*/
|
*/
|
||||||
static void shellDisplayItem(SHELL_TypeDef *shell, unsigned short index)
|
static void shellDisplayItem(SHELL_TypeDef *shell, unsigned short index)
|
||||||
{
|
{
|
||||||
unsigned short spaceLength;
|
short spaceLength;
|
||||||
SHELL_CommandTypeDef *base = shell->commandBase;
|
SHELL_CommandTypeDef *base = shell->commandBase;
|
||||||
|
|
||||||
spaceLength = 22 - shellDisplay(shell, (base + index)->name);
|
spaceLength = 22 - shellDisplay(shell, (base + index)->name);
|
||||||
|
6
shell.h
6
shell.h
@ -118,7 +118,7 @@
|
|||||||
const SHELL_CommandTypeDef \
|
const SHELL_CommandTypeDef \
|
||||||
shellCommand##cmd SECTION("shellCommand") = \
|
shellCommand##cmd SECTION("shellCommand") = \
|
||||||
{ \
|
{ \
|
||||||
shellCmd##cmd \
|
shellCmd##cmd, \
|
||||||
(int (*)())func, \
|
(int (*)())func, \
|
||||||
shellDesc##cmd \
|
shellDesc##cmd \
|
||||||
}
|
}
|
||||||
@ -142,7 +142,7 @@
|
|||||||
shellVariable##var SECTION("shellVariable") = \
|
shellVariable##var SECTION("shellVariable") = \
|
||||||
{ \
|
{ \
|
||||||
shellVar##var, \
|
shellVar##var, \
|
||||||
(void *)(variable), \
|
(void *)(variable), \
|
||||||
shellDesc##var, \
|
shellDesc##var, \
|
||||||
type \
|
type \
|
||||||
}
|
}
|
||||||
@ -314,10 +314,10 @@ typedef struct
|
|||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
char inputMode : 2; /**< 输入模式 */
|
char inputMode : 2; /**< 输入模式 */
|
||||||
|
char isActive: 1; /**< 是否是当前活动shell */
|
||||||
char tabFlag : 1; /**< tab标志 */
|
char tabFlag : 1; /**< tab标志 */
|
||||||
char authFlag : 1; /**< 密码标志 */
|
char authFlag : 1; /**< 密码标志 */
|
||||||
} status; /**< shell状态 */
|
} status; /**< shell状态 */
|
||||||
unsigned char isActive; /**< 是否是当前活动shell */
|
|
||||||
shellRead read; /**< shell读字符 */
|
shellRead read; /**< shell读字符 */
|
||||||
shellWrite write; /**< shell写字符 */
|
shellWrite write; /**< shell写字符 */
|
||||||
#if SHELL_LONG_HELP == 1 || (SHELL_USING_AUTH && SHELL_LOCK_TIMEOUT > 0)
|
#if SHELL_LONG_HELP == 1 || (SHELL_USING_AUTH && SHELL_LOCK_TIMEOUT > 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user