From 0002c2314c13fd20b5288d287f60bb3a904abf8d Mon Sep 17 00:00:00 2001 From: apio Date: Mon, 4 Sep 2023 13:12:08 +0200 Subject: [PATCH] kernel: Handle tab properly in the terminal --- kernel/src/arch/x86_64/Keyboard.cpp | 7 +++---- kernel/src/fs/devices/ConsoleDevice.cpp | 3 ++- kernel/src/video/TextConsole.cpp | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/src/arch/x86_64/Keyboard.cpp b/kernel/src/arch/x86_64/Keyboard.cpp index 6eb071b6..9bc14272 100644 --- a/kernel/src/arch/x86_64/Keyboard.cpp +++ b/kernel/src/arch/x86_64/Keyboard.cpp @@ -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', ':', '"', '~', diff --git a/kernel/src/fs/devices/ConsoleDevice.cpp b/kernel/src/fs/devices/ConsoleDevice.cpp index 16846414..4037cf3c 100644 --- a/kernel/src/fs/devices/ConsoleDevice.cpp +++ b/kernel/src/fs/devices/ConsoleDevice.cpp @@ -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) { diff --git a/kernel/src/video/TextConsole.cpp b/kernel/src/video/TextConsole.cpp index efc41612..ea49ac90 100644 --- a/kernel/src/video/TextConsole.cpp +++ b/kernel/src/video/TextConsole.cpp @@ -346,7 +346,7 @@ namespace TextConsole break; } case L'\t': { - wprint(L" "); + wprint(L" "); break; } case L'\r': g_x_position = 0; break;