From d68ad893f08f55e151cfaafd9c07cf8a0ebb8abc Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sat, 14 Sep 2024 22:45:48 +0300 Subject: [PATCH] Kernel/Shell: Add support for delete key --- kernel/kernel/Terminal/TTY.cpp | 3 +++ userspace/programs/Shell/main.cpp | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/kernel/kernel/Terminal/TTY.cpp b/kernel/kernel/Terminal/TTY.cpp index 2f5b3d69..b6024ef2 100644 --- a/kernel/kernel/Terminal/TTY.cpp +++ b/kernel/kernel/Terminal/TTY.cpp @@ -222,6 +222,9 @@ namespace Kernel case LibInput::Key::Escape: ansi_c_str = "\e"; break; + case LibInput::Key::Delete: + ansi_c_str = "\x7F"; + break; case LibInput::Key::ArrowUp: ansi_c_str = "\e[A"; break; diff --git a/userspace/programs/Shell/main.cpp b/userspace/programs/Shell/main.cpp index 1d8fbf03..d016a635 100644 --- a/userspace/programs/Shell/main.cpp +++ b/userspace/programs/Shell/main.cpp @@ -892,6 +892,16 @@ int main(int argc, char** argv) putchar('\n'); clean_exit(0); break; + case '\x7F': // delete + if (col < buffers[index].size()) + { + buffers[index].remove(col); + while (col < buffers[index].size() && (buffers[index][col] & 0xC0) == 0x80) + buffers[index].remove(col); + printf("\e[s%s \e[u", buffers[index].data() + col); + fflush(stdout); + } + break; case '\n': putchar('\n'); if (!buffers[index].empty())