Clear stale terminal frames on resize
This commit is contained in:
@@ -37,9 +37,6 @@ final class TerminalScreenBuffer {
|
|||||||
void resize(int nextCols, int nextRows) {
|
void resize(int nextCols, int nextRows) {
|
||||||
nextCols = Math.max(1, nextCols);
|
nextCols = Math.max(1, nextCols);
|
||||||
nextRows = Math.max(1, nextRows);
|
nextRows = Math.max(1, nextRows);
|
||||||
Cell[][] previous = cells;
|
|
||||||
int previousRows = rows;
|
|
||||||
int previousCols = cols;
|
|
||||||
cols = nextCols;
|
cols = nextCols;
|
||||||
rows = nextRows;
|
rows = nextRows;
|
||||||
cells = new Cell[rows][cols];
|
cells = new Cell[rows][cols];
|
||||||
@@ -48,21 +45,11 @@ final class TerminalScreenBuffer {
|
|||||||
cells[row][col] = new Cell();
|
cells[row][col] = new Cell();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (previous != null) {
|
cursorRow = 0;
|
||||||
int copyRows = Math.min(previousRows, rows);
|
cursorCol = 0;
|
||||||
int copyCols = Math.min(previousCols, cols);
|
savedRow = 0;
|
||||||
int previousStart = Math.max(0, previousRows - copyRows);
|
savedCol = 0;
|
||||||
int nextStart = Math.max(0, rows - copyRows);
|
wrapPending = false;
|
||||||
for (int row = 0; row < copyRows; row++) {
|
|
||||||
for (int col = 0; col < copyCols; col++) {
|
|
||||||
cells[nextStart + row][col].copyFrom(previous[previousStart + row][col]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cursorRow = clamp(cursorRow, 0, rows - 1);
|
|
||||||
cursorCol = clamp(cursorCol, 0, cols - 1);
|
|
||||||
savedRow = clamp(savedRow, 0, rows - 1);
|
|
||||||
savedCol = clamp(savedCol, 0, cols - 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
|
|||||||
Reference in New Issue
Block a user