summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-12-07 00:17:23 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-12-07 00:19:08 +0100
commit87b10f6e6efea9c1d1d84b4d1f1bd93fc453d652 (patch)
tree0f1269f000bfcb8bc8d85ccb34d7bbbfe292fa5e /Kernel
parentf18c985546341f45276adf2e01dc9ab3765c26cf (diff)
downloadserenity-87b10f6e6efea9c1d1d84b4d1f1bd93fc453d652.zip
Add basic support for horizontal tabs in the VirtualConsole.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/VirtualConsole.cpp15
-rw-r--r--Kernel/VirtualConsole.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/Kernel/VirtualConsole.cpp b/Kernel/VirtualConsole.cpp
index 379f55421d..6147befc87 100644
--- a/Kernel/VirtualConsole.cpp
+++ b/Kernel/VirtualConsole.cpp
@@ -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);
diff --git a/Kernel/VirtualConsole.h b/Kernel/VirtualConsole.h
index 75b54e82f2..76be9b45bf 100644
--- a/Kernel/VirtualConsole.h
+++ b/Kernel/VirtualConsole.h
@@ -73,4 +73,5 @@ private:
EscapeState m_escape_state { Normal };
Vector<byte> m_parameters;
Vector<byte> m_intermediates;
+ byte* m_horizontal_tabs { nullptr };
};