From ada8b1087d2b07bb9785e6b6ec5e6448445d3b2c Mon Sep 17 00:00:00 2001 From: Leroy Hopson Date: Fri, 25 Sep 2020 10:25:46 +0700 Subject: [PATCH] Copy old cells to new cells when resizing Previously all cells were erased which resulted in the screen becoming blank in some places until it was redrawn. --- addons/godot_xterm/native/src/terminal.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/addons/godot_xterm/native/src/terminal.cpp b/addons/godot_xterm/native/src/terminal.cpp index e9d33da..30d75ee 100644 --- a/addons/godot_xterm/native/src/terminal.cpp +++ b/addons/godot_xterm/native/src/terminal.cpp @@ -536,7 +536,7 @@ void Terminal::update_size() Godot::print(String("resized_rows: {0}, resized_cols: {1}").format(Array::make(rows, cols))); - cells = {}; + Cells new_cells = {}; for (int x = 0; x < rows; x++) { @@ -544,12 +544,21 @@ void Terminal::update_size() for (int y = 0; y < cols; y++) { - row[y] = empty_cell; + if (x < cells.size() && y < cells[x].size()) + { + row[y] = cells[x][y]; + } + else + { + row[y] = empty_cell; + } } - cells.push_back(row); + new_cells.push_back(row); } + cells = new_cells; + tsm_screen_resize(screen, cols, rows); sleep = false;