summaryrefslogtreecommitdiff
path: root/Kernel/TTY
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-05-23 15:47:41 +0200
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-05-24 22:26:54 +0430
commit146bd794eb8167db15206f112ff2e4dd8a00492d (patch)
tree109687a08d34ddf93278372e64ab88b52f71094b /Kernel/TTY
parentcb8d0c8d0d139b0212a91355972000ba79392960 (diff)
downloadserenity-146bd794eb8167db15206f112ff2e4dd8a00492d.zip
LibVT: Add Alternate Screen Buffer support
The Alternate Screen Buffer is used by full-screen terminal applications (like `vim` and `nano`). Its data is stored separately from the normal buffer, therefore after applications using it exit, everything looks like it was before, the bottom of their interfaces isn't visible. An interesting feature is that it does not support scrollback, so it consumes less memory by not having to allocate lines for history. Because of the need to save and restore state between the switches, some correctness issues relating to it were also fixed in this commit.
Diffstat (limited to 'Kernel/TTY')
-rw-r--r--Kernel/TTY/VirtualConsole.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/Kernel/TTY/VirtualConsole.cpp b/Kernel/TTY/VirtualConsole.cpp
index feaec5ad4f..fe77f24704 100644
--- a/Kernel/TTY/VirtualConsole.cpp
+++ b/Kernel/TTY/VirtualConsole.cpp
@@ -47,11 +47,10 @@ void ConsoleImpl::set_size(u16 determined_columns, u16 determined_rows)
m_columns = determined_columns;
m_rows = determined_rows;
- m_cursor_row = min<size_t>((int)m_cursor_row, rows() - 1);
- m_cursor_column = min<size_t>((int)m_cursor_column, columns() - 1);
- m_saved_cursor_row = min<size_t>((int)m_saved_cursor_row, rows() - 1);
- m_saved_cursor_column = min<size_t>((int)m_saved_cursor_column, columns() - 1);
-
+ m_current_state.cursor.clamp(rows() - 1, columns() - 1);
+ m_normal_saved_state.cursor.clamp(rows() - 1, columns() - 1);
+ m_alternate_saved_state.cursor.clamp(rows() - 1, columns() - 1);
+ m_saved_cursor_position.clamp(rows() - 1, columns() - 1);
m_horizontal_tabs.resize(determined_columns);
for (unsigned i = 0; i < determined_columns; ++i)
m_horizontal_tabs[i] = (i % 8) == 0;
@@ -62,7 +61,7 @@ void ConsoleImpl::set_size(u16 determined_columns, u16 determined_rows)
void ConsoleImpl::scroll_up()
{
// NOTE: We have to invalidate the cursor first.
- m_client.invalidate_cursor(m_cursor_row);
+ m_client.invalidate_cursor(cursor_row());
m_client.scroll_up();
}
void ConsoleImpl::scroll_down()
@@ -70,7 +69,7 @@ void ConsoleImpl::scroll_down()
}
void ConsoleImpl::linefeed()
{
- u16 new_row = m_cursor_row;
+ u16 new_row = cursor_row();
u16 max_row = rows() - 1;
if (new_row == max_row) {
// NOTE: We have to invalidate the cursor first.
@@ -83,7 +82,7 @@ void ConsoleImpl::linefeed()
}
void ConsoleImpl::put_character_at(unsigned row, unsigned column, u32 ch)
{
- m_client.put_character_at(row, column, ch, m_current_attribute);
+ m_client.put_character_at(row, column, ch, m_current_state.attribute);
m_last_code_point = ch;
}
void ConsoleImpl::set_window_title(const String&)