diff --git a/CLI/CLI.c b/CLI/CLI.c index 4825a58..6f9d085 100644 --- a/CLI/CLI.c +++ b/CLI/CLI.c @@ -119,6 +119,11 @@ void historyPrevius() // add current text to end of history line = fifoToString(FIFO); History_put(History, line); + for (int i=0; *(line + i) != '\0'; i++) + { + CLI_stringOut((char*)"\x1b[D \x1b[D"); + } + History_getPrev(History, &line); } // empty current line @@ -267,9 +272,9 @@ bool CLI_charIn(char c) { #ifdef HISTORY case 'A': // arrow up + CLI_State = CLI_State_Default; historyPrevius(); // CLI_stringOut((char*)"(key: arrow up)"); - CLI_State = CLI_State_Default; break; case 'B': // arrow down // history next diff --git a/History/History.c b/History/History.c index 612c6d2..74bdca0 100644 --- a/History/History.c +++ b/History/History.c @@ -100,10 +100,14 @@ int History_getPrev(History_t* history, char** line) { history->CurrEl_p = history->LastEl_p; } - else + else if (history->CurrEl_p->prevEl_p != NULL) { history->CurrEl_p = history->CurrEl_p->prevEl_p; } + else + { // no previus line + retCode = -2; + } if (history->CurrEl_p != NULL) { @@ -111,7 +115,7 @@ int History_getPrev(History_t* history, char** line) retCode = 0; } else - { + { // no items in history? *line = NULL; retCode = -1; }