Add basic support for horizontal tabs in the VirtualConsole.

This commit is contained in:
Andreas Kling 2018-12-07 00:17:23 +01:00
parent f18c985546
commit 87b10f6e6e
Notes: sideshowbarker 2024-07-19 16:08:22 +09:00
2 changed files with 16 additions and 0 deletions

View File

@ -42,6 +42,10 @@ VirtualConsole::VirtualConsole(unsigned index, InitialContents initial_contents)
, m_index(index)
{
set_size(80, 25);
m_horizontal_tabs = static_cast<byte*>(kmalloc(columns()));
for (unsigned i = 0; i < columns(); ++i)
m_horizontal_tabs[i] = (i % 8) == 0;
s_consoles[index] = this;
m_buffer = (byte*)kmalloc_eternal(rows() * columns() * 2);
if (initial_contents == AdoptCurrentVGABuffer) {
@ -56,6 +60,8 @@ VirtualConsole::VirtualConsole(unsigned index, InitialContents initial_contents)
VirtualConsole::~VirtualConsole()
{
kfree(m_horizontal_tabs);
m_horizontal_tabs = nullptr;
}
void VirtualConsole::clear()
@ -427,6 +433,15 @@ void VirtualConsole::on_char(byte ch)
return;
}
break;
case '\t': {
for (unsigned i = m_cursor_column; i < columns(); ++i) {
if (m_horizontal_tabs[i]) {
set_cursor(m_cursor_row, i);
return;
}
}
return;
}
case '\n':
scroll_up();
set_cursor(m_cursor_row, m_cursor_column);

View File

@ -73,4 +73,5 @@ private:
EscapeState m_escape_state { Normal };
Vector<byte> m_parameters;
Vector<byte> m_intermediates;
byte* m_horizontal_tabs { nullptr };
};