mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:08:10 +00:00
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.
This commit is contained in:
parent
cb8d0c8d0d
commit
146bd794eb
3 changed files with 275 additions and 181 deletions
|
@ -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&)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue