mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:57:45 +00:00
Terminal: Try to preserve line contents when resizing the terminal window.
This is still destructive when shrinking, but clearly better than throwing everything away.
This commit is contained in:
parent
4d904340b4
commit
2c81477f16
2 changed files with 12 additions and 8 deletions
|
@ -87,6 +87,10 @@ void Terminal::Line::set_length(u16 new_length)
|
||||||
auto* new_characters = new u8[new_length];
|
auto* new_characters = new u8[new_length];
|
||||||
auto* new_attributes = new Attribute[new_length];
|
auto* new_attributes = new Attribute[new_length];
|
||||||
memset(new_characters, ' ', new_length);
|
memset(new_characters, ' ', new_length);
|
||||||
|
if (characters && attributes) {
|
||||||
|
memcpy(new_characters, characters, min(m_length, new_length));
|
||||||
|
memcpy(new_attributes, attributes, min(m_length, new_length) * sizeof(Attribute));
|
||||||
|
}
|
||||||
delete[] characters;
|
delete[] characters;
|
||||||
delete[] attributes;
|
delete[] attributes;
|
||||||
characters = new_characters;
|
characters = new_characters;
|
||||||
|
@ -938,10 +942,10 @@ void Terminal::set_size(u16 columns, u16 rows)
|
||||||
m_scroll_region_top = 0;
|
m_scroll_region_top = 0;
|
||||||
m_scroll_region_bottom = rows - 1;
|
m_scroll_region_bottom = rows - 1;
|
||||||
|
|
||||||
m_cursor_row = 0;
|
m_cursor_row = min((int)m_cursor_row, m_rows - 1);
|
||||||
m_cursor_column = 0;
|
m_cursor_column = min((int)m_cursor_column, m_columns - 1);
|
||||||
m_saved_cursor_row = 0;
|
m_saved_cursor_row = min((int)m_saved_cursor_row, m_rows - 1);
|
||||||
m_saved_cursor_column = 0;
|
m_saved_cursor_column = min((int)m_saved_cursor_column, m_columns - 1);
|
||||||
|
|
||||||
m_horizontal_tabs.resize(columns);
|
m_horizontal_tabs.resize(columns);
|
||||||
for (unsigned i = 0; i < columns; ++i)
|
for (unsigned i = 0; i < columns; ++i)
|
||||||
|
|
|
@ -212,10 +212,10 @@ private:
|
||||||
u16 m_columns { 0 };
|
u16 m_columns { 0 };
|
||||||
u16 m_rows { 0 };
|
u16 m_rows { 0 };
|
||||||
|
|
||||||
u8 m_cursor_row { 0 };
|
u16 m_cursor_row { 0 };
|
||||||
u8 m_cursor_column { 0 };
|
u16 m_cursor_column { 0 };
|
||||||
u8 m_saved_cursor_row { 0 };
|
u16 m_saved_cursor_row { 0 };
|
||||||
u8 m_saved_cursor_column { 0 };
|
u16 m_saved_cursor_column { 0 };
|
||||||
bool m_stomp { false };
|
bool m_stomp { false };
|
||||||
|
|
||||||
bool m_should_beep { false };
|
bool m_should_beep { false };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue