diff --git a/CLI/CLI.c b/CLI/CLI.c index 6f9d085..a4544b1 100644 --- a/CLI/CLI.c +++ b/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 int tryExecute(FIFOBuffChar_t* fifo) @@ -274,12 +296,10 @@ bool CLI_charIn(char c) case 'A': // arrow up CLI_State = CLI_State_Default; historyPrevius(); - // CLI_stringOut((char*)"(key: arrow up)"); break; case 'B': // arrow down - // history next - CLI_stringOut((char*)"(key: arrow down)"); CLI_State = CLI_State_Default; + historyNext(); break; case 'C': // arrow right CLI_stringOut((char*)"(key: arrow right)");