ConsoleDevice: Use a temporary buffer for backspace handling
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
83492339ec
commit
cda036ce70
@ -2,6 +2,7 @@
|
||||
#include "video/TextConsole.h"
|
||||
#include <luna/Buffer.h>
|
||||
#include <luna/CString.h>
|
||||
#include <luna/Vector.h>
|
||||
|
||||
static Buffer g_console_input;
|
||||
|
||||
@ -34,7 +35,24 @@ bool ConsoleDevice::blocking() const
|
||||
return g_console_input.size() == 0;
|
||||
}
|
||||
|
||||
static Vector<u8> g_temp_input;
|
||||
|
||||
void ConsoleDevice::did_press_key(char key)
|
||||
{
|
||||
*g_console_input.slice_at_end(1).value() = (u8)key;
|
||||
if (key == '\b')
|
||||
{
|
||||
if (g_temp_input.try_pop().has_value()) TextConsole::putwchar(L'\b');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
g_temp_input.try_append(key).value();
|
||||
|
||||
if (key == '\n')
|
||||
{
|
||||
g_console_input.append_data(g_temp_input.data(), g_temp_input.size()).value();
|
||||
g_temp_input.clear();
|
||||
}
|
||||
|
||||
TextConsole::putchar(key);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user