Prototype of the history for user inputs.

Change-Id: I676e8b80ec092891117827eda5213c6f1cfac733
This commit is contained in:
Felix Raimundo
2016-04-06 15:19:31 +02:00
parent 23aef52622
commit 4e8ee1bf02
2 changed files with 51 additions and 14 deletions

View File

@@ -111,14 +111,17 @@ text_event_t get_text(char* txt) {
char input[255] = {0};
int index = 0;
int max = 0;
input[max] = ' ';
input[max+1] = '\0';
text_event_t text_event = {nullptr, ERROR};
if (txt != nullptr) {
assert(false);
index = strlen(txt);
max = index;
memcpy(input, txt, (size_t) index);
}
input[max] = ' ';
input[max+1] = '\0';
while (1) {
clear_prompt();
print_prompt(input, index);
@@ -165,9 +168,17 @@ text_event_t get_text(char* txt) {
input[i] = input[i+1];
}
max--;
} else if (event == UP_ARROW) {
text_event.event = UP_ARROW;
break;
} else if (event == DOWN_ARROW) {
text_event.event = DOWN_ARROW;
break;
} else {
assert(false); // unreachable.
}
}
clear_prompt();
return text_event;
}