Kernel: Add ANSI support for hiding/showing cursor to TTY
This commit is contained in:
parent
7184514b5d
commit
04cfbca336
|
@ -63,6 +63,7 @@ namespace Kernel
|
||||||
{
|
{
|
||||||
int32_t nums[2] { -1, -1 };
|
int32_t nums[2] { -1, -1 };
|
||||||
int32_t index { 0 };
|
int32_t index { 0 };
|
||||||
|
bool question { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UTF8State
|
struct UTF8State
|
||||||
|
@ -94,6 +95,7 @@ namespace Kernel
|
||||||
uint32_t m_row { 0 };
|
uint32_t m_row { 0 };
|
||||||
uint32_t m_column { 0 };
|
uint32_t m_column { 0 };
|
||||||
Cell* m_buffer { nullptr };
|
Cell* m_buffer { nullptr };
|
||||||
|
bool m_show_cursor { true };
|
||||||
|
|
||||||
TerminalDriver::Color m_foreground { TerminalColor::BRIGHT_WHITE };
|
TerminalDriver::Color m_foreground { TerminalColor::BRIGHT_WHITE };
|
||||||
TerminalDriver::Color m_background { TerminalColor::BLACK };
|
TerminalDriver::Color m_background { TerminalColor::BLACK };
|
||||||
|
|
|
@ -308,7 +308,8 @@ flush:
|
||||||
static uint32_t last_y = -1;
|
static uint32_t last_y = -1;
|
||||||
if (last_x != uint32_t(-1) && last_y != uint32_t(-1))
|
if (last_x != uint32_t(-1) && last_y != uint32_t(-1))
|
||||||
render_from_buffer(last_x, last_y);
|
render_from_buffer(last_x, last_y);
|
||||||
m_terminal_driver->set_cursor_position(x, y);
|
if (m_show_cursor)
|
||||||
|
m_terminal_driver->set_cursor_position(x, y);
|
||||||
last_x = m_column = x;
|
last_x = m_column = x;
|
||||||
last_y = m_row = y;
|
last_y = m_row = y;
|
||||||
}
|
}
|
||||||
|
@ -348,6 +349,7 @@ flush:
|
||||||
m_ansi_state.index = 0;
|
m_ansi_state.index = 0;
|
||||||
m_ansi_state.nums[0] = -1;
|
m_ansi_state.nums[0] = -1;
|
||||||
m_ansi_state.nums[1] = -1;
|
m_ansi_state.nums[1] = -1;
|
||||||
|
m_ansi_state.question = false;
|
||||||
m_state = State::Normal;
|
m_state = State::Normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,6 +503,24 @@ flush:
|
||||||
m_row = m_saved_row;
|
m_row = m_saved_row;
|
||||||
m_column = m_saved_column;
|
m_column = m_saved_column;
|
||||||
return reset_ansi();
|
return reset_ansi();
|
||||||
|
|
||||||
|
case '?':
|
||||||
|
if (m_ansi_state.index != 0 || m_ansi_state.nums[0] != -1)
|
||||||
|
{
|
||||||
|
dprintln("invalid ANSI CSI ?");
|
||||||
|
return reset_ansi();
|
||||||
|
}
|
||||||
|
m_ansi_state.question = true;
|
||||||
|
return;
|
||||||
|
case 'h':
|
||||||
|
case 'l':
|
||||||
|
if (!m_ansi_state.question || m_ansi_state.nums[0] != 25)
|
||||||
|
{
|
||||||
|
dprintln("invalid ANSI CSI ?{}{}", m_ansi_state.nums[0], (char)ch);
|
||||||
|
return reset_ansi();
|
||||||
|
}
|
||||||
|
m_show_cursor = (ch == 'h');
|
||||||
|
return reset_ansi();
|
||||||
default:
|
default:
|
||||||
dprintln("Unsupported ANSI CSI character {}", ch);
|
dprintln("Unsupported ANSI CSI character {}", ch);
|
||||||
return reset_ansi();
|
return reset_ansi();
|
||||||
|
|
Loading…
Reference in New Issue