mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-24 16:20:49 +01:00
Prototype of the history for user inputs.
Change-Id: I676e8b80ec092891117827eda5213c6f1cfac733
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user