[+] ConsoleTTY history (unsaved)

This commit is contained in:
Reece Wilson 2022-05-19 04:21:34 +01:00
parent 4079d471a7
commit 537ffca394
2 changed files with 73 additions and 5 deletions

View File

@ -88,7 +88,7 @@ namespace Aurora::Console::ConsoleTTY
ConsoleStd::NoncanonicalTick();
auto inputs = ConsoleStd::DequeueNoncanonicalInput();
if (inputs.size())
if (inputs.size() && PermitDoubleBuffering())
{
BeginBuffering();
}
@ -124,12 +124,32 @@ namespace Aurora::Console::ConsoleTTY
}
case ConsoleStd::ENoncanonicalInput::eArrowDown:
{
NoncanonicalOnMenuDown();
if (this->noncanonicalCursorPosInBytes == 0 ||
this->GetHintLines() == 0)
{
NoncanonicalOnHistoryDown();
}
else
{
NoncanonicalOnMenuDown();
}
break;
}
case ConsoleStd::ENoncanonicalInput::eArrowUp:
{
NoncanonicalOnMenuUp();
if (this->noncanonicalCursorPosInBytes == 0 ||
this->GetHintLines() == 0)
{
NoncanonicalOnHistoryUp();
}
else
{
NoncanonicalOnMenuUp();
}
break;
}
case ConsoleStd::ENoncanonicalInput::eScroll:
@ -144,7 +164,7 @@ namespace Aurora::Console::ConsoleTTY
};
}
if (inputs.size())
if (inputs.size() && PermitDoubleBuffering())
{
EndBuffering();
}
@ -273,6 +293,8 @@ namespace Aurora::Console::ConsoleTTY
}
}
AuTryInsert(this->history, this->inputField);
this->noncanonicalCursorPos = 0;
this->noncanonicalCursorPosInBytes = 0;
this->inputField.clear();
@ -292,12 +314,52 @@ namespace Aurora::Console::ConsoleTTY
void TTYConsole::NoncanonicalOnMenuUp()
{
}
void TTYConsole::NoncanonicalOnMenuDown()
{
}
void TTYConsole::NoncanonicalOnHistoryUp()
{
if (this->iHistoryPos == -1)
{
this->iHistoryPos = this->history.size();
}
this->iHistoryPos--;
if (this->iHistoryPos < 0)
{
this->iHistoryPos = 0;
}
this->inputField = this->history[this->iHistoryPos];
RedrawInput(true);
//NoncanonicalSetCursor();
}
void TTYConsole::NoncanonicalOnHistoryDown()
{
if (this->iHistoryPos == -1)
{
return;
}
this->iHistoryPos++;
if (this->iHistoryPos >= this->history.size())
{
this->iHistoryPos = -1;
this->inputField.clear();
}
else
{
this->inputField = this->history[this->iHistoryPos];
}
RedrawInput(true);
//NoncanonicalSetCursor();
}
void TTYConsole::Scroll(int delta)

View File

@ -61,6 +61,9 @@ namespace Aurora::Console::ConsoleTTY
void NoncanonicalOnMenuUp();
void NoncanonicalOnMenuDown();
void NoncanonicalOnHistoryUp();
void NoncanonicalOnHistoryDown();
int noncanonicalCursorPos {};
int noncanonicalCursorPosInBytes {};
@ -154,6 +157,9 @@ namespace Aurora::Console::ConsoleTTY
int oldHeight {};
int iHistoryPos {-1};
AuList<AuString> history;
AuThreadPrimitives::SpinLock messageLock;
AuList<AuConsole::ConsoleMessage> messagesPending;