CLI: add history next
This commit is contained in:
parent
73c0013ee9
commit
0eed939e87
26
CLI/CLI.c
26
CLI/CLI.c
@ -145,6 +145,28 @@ void historyPrevius()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void historyNext()
|
||||||
|
{
|
||||||
|
char* line;
|
||||||
|
// empty current line
|
||||||
|
while (FIFOBuffChar_getSize(FIFO) > 0)
|
||||||
|
{
|
||||||
|
CLI_stringOut((char*)"\x1b[D \x1b[D");
|
||||||
|
FIFOBuffChar_pop(FIFO);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get next command
|
||||||
|
int ret = History_getNext(History, &line);
|
||||||
|
|
||||||
|
// write line
|
||||||
|
if ((ret >= 0) && (line != NULL))
|
||||||
|
{
|
||||||
|
for (int i=0; *(line + i) != '\0'; i++)
|
||||||
|
{
|
||||||
|
CLI_charIn(*(line + i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int tryExecute(FIFOBuffChar_t* fifo)
|
int tryExecute(FIFOBuffChar_t* fifo)
|
||||||
@ -274,12 +296,10 @@ bool CLI_charIn(char c)
|
|||||||
case 'A': // arrow up
|
case 'A': // arrow up
|
||||||
CLI_State = CLI_State_Default;
|
CLI_State = CLI_State_Default;
|
||||||
historyPrevius();
|
historyPrevius();
|
||||||
// CLI_stringOut((char*)"(key: arrow up)");
|
|
||||||
break;
|
break;
|
||||||
case 'B': // arrow down
|
case 'B': // arrow down
|
||||||
// history next
|
|
||||||
CLI_stringOut((char*)"(key: arrow down)");
|
|
||||||
CLI_State = CLI_State_Default;
|
CLI_State = CLI_State_Default;
|
||||||
|
historyNext();
|
||||||
break;
|
break;
|
||||||
case 'C': // arrow right
|
case 'C': // arrow right
|
||||||
CLI_stringOut((char*)"(key: arrow right)");
|
CLI_stringOut((char*)"(key: arrow right)");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user