Kernel/Shell: Add support for delete key

This commit is contained in:
Bananymous 2024-09-14 22:45:48 +03:00
parent 4ca147699d
commit d68ad893f0
2 changed files with 13 additions and 0 deletions

View File

@ -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;

View File

@ -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())