mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 10:19:03 +03: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
Notes:
sideshowbarker
2024-07-19 13:21:52 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/2c81477f167
@ -87,6 +87,10 @@ void Terminal::Line::set_length(u16 new_length)
|
||||
auto* new_characters = new u8[new_length];
|
||||
auto* new_attributes = new Attribute[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[] attributes;
|
||||
characters = new_characters;
|
||||
@ -938,10 +942,10 @@ void Terminal::set_size(u16 columns, u16 rows)
|
||||
m_scroll_region_top = 0;
|
||||
m_scroll_region_bottom = rows - 1;
|
||||
|
||||
m_cursor_row = 0;
|
||||
m_cursor_column = 0;
|
||||
m_saved_cursor_row = 0;
|
||||
m_saved_cursor_column = 0;
|
||||
m_cursor_row = min((int)m_cursor_row, m_rows - 1);
|
||||
m_cursor_column = min((int)m_cursor_column, m_columns - 1);
|
||||
m_saved_cursor_row = min((int)m_saved_cursor_row, m_rows - 1);
|
||||
m_saved_cursor_column = min((int)m_saved_cursor_column, m_columns - 1);
|
||||
|
||||
m_horizontal_tabs.resize(columns);
|
||||
for (unsigned i = 0; i < columns; ++i)
|
||||
|
@ -212,10 +212,10 @@ private:
|
||||
u16 m_columns { 0 };
|
||||
u16 m_rows { 0 };
|
||||
|
||||
u8 m_cursor_row { 0 };
|
||||
u8 m_cursor_column { 0 };
|
||||
u8 m_saved_cursor_row { 0 };
|
||||
u8 m_saved_cursor_column { 0 };
|
||||
u16 m_cursor_row { 0 };
|
||||
u16 m_cursor_column { 0 };
|
||||
u16 m_saved_cursor_row { 0 };
|
||||
u16 m_saved_cursor_column { 0 };
|
||||
bool m_stomp { false };
|
||||
|
||||
bool m_should_beep { false };
|
||||
|
Loading…
Reference in New Issue
Block a user