kernel: Handle tab properly in the terminal

This commit is contained in:
apio 2023-09-04 13:12:08 +02:00
parent 27eacac19c
commit 0002c2314c
Signed by: apio
GPG Key ID: B8A7D06E42258954
3 changed files with 6 additions and 6 deletions

View File

@ -19,21 +19,20 @@ constexpr u8 RIGHT_SHIFT = 0x36;
constexpr u8 CAPS_LOCK = 0x3a;
constexpr u8 LEFT_CONTROL = 0x1D;
constexpr u8 TAB = 0x0F;
constexpr u8 LEFT_ALT = 0x38;
constexpr u8 F11 = 0x57;
constexpr u8 F12 = 0x58;
static bool should_ignore_key(u8 scancode)
{
return (scancode > 0x3A && scancode < 0x47) || scancode == TAB || scancode == F11 || scancode == F12;
return (scancode > 0x3A && scancode < 0x47) || scancode == F11 || scancode == F12;
}
constexpr char key_table[] = {
'\0',
'\1', // escape
'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b',
'\0', // tab
'\t', // tab
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n',
'\0', // left ctrl
'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`',
@ -75,7 +74,7 @@ constexpr char shifted_key_table[] = {
'\0',
'\1', // escape
'!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '\b',
'\0', // tab
'\t', // tab
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', '\n',
'\0', // left ctrl
'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~',

View File

@ -106,6 +106,7 @@ void ConsoleDevice::process_key_event(u8 scancode)
{
TextConsole::putwchar(L'\b');
if (_iscntrl(maybe_char.value())) TextConsole::putwchar(L'\b');
if (maybe_char.value() == '\t') TextConsole::wprint(L"\b\b");
}
return;
}
@ -179,7 +180,7 @@ void ConsoleDevice::process_key_event(u8 scancode)
if (m_settings.c_lflag & ECHOCTL)
{
bool should_echo = true;
if (key == '\n' || key == '\0' || key == m_settings.c_cc[VEOF]) should_echo = false;
if (key == '\n' || key == '\t' || key == '\0' || key == m_settings.c_cc[VEOF]) should_echo = false;
if (should_echo)
{