forked from Bananymous/banan-os
Kernel: Add partial support for shell
We don't handle arrow keys, and the tty does not know how to clear the screeen :D
This commit is contained in:
@@ -92,6 +92,7 @@ namespace Kernel
|
||||
ansi = "\n";
|
||||
break;
|
||||
case Input::Key::Backspace:
|
||||
ansi = nullptr;
|
||||
if (m_output.bytes > 0)
|
||||
{
|
||||
// Multibyte UTF8
|
||||
@@ -103,19 +104,20 @@ namespace Kernel
|
||||
ASSERT(m_output.bytes > 0);
|
||||
m_output.bytes--;
|
||||
}
|
||||
ansi = "\b \b";
|
||||
do_backspace();
|
||||
}
|
||||
// Control sequence
|
||||
else if (m_output.bytes >= 2 && m_output.buffer[m_output.bytes - 2] == '\e')
|
||||
{
|
||||
m_output.bytes -= 2;
|
||||
ansi = "\b\b \b\b";
|
||||
do_backspace();
|
||||
do_backspace();
|
||||
}
|
||||
// Ascii
|
||||
else
|
||||
{
|
||||
m_output.bytes--;
|
||||
ansi = "\b \b";
|
||||
do_backspace();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -156,6 +158,16 @@ namespace Kernel
|
||||
m_terminal_driver->clear(m_background);
|
||||
}
|
||||
|
||||
void TTY::do_backspace()
|
||||
{
|
||||
if (m_column > 0)
|
||||
{
|
||||
m_column--;
|
||||
putchar_at(' ', m_column, m_row);
|
||||
set_cursor_position(m_column, m_row);
|
||||
}
|
||||
}
|
||||
|
||||
void TTY::set_cursor_position(uint32_t x, uint32_t y)
|
||||
{
|
||||
static uint32_t last_x = -1;
|
||||
|
||||
Reference in New Issue
Block a user