on resize, make sure we resize the alt screen too

This commit is contained in:
Mitchell Hashimoto
2022-07-22 14:22:53 -07:00
parent 12a864c3f2
commit dfde2acf10
2 changed files with 5 additions and 4 deletions

View File

@ -346,6 +346,10 @@ pub fn resize(self: *Screen, alloc: Allocator, rows: usize, cols: usize) !void {
self.rows = rows;
self.cols = cols;
// Move our cursor if we have to so it stays on the screen.
self.cursor.x = @minimum(self.cursor.x, self.cols - 1);
self.cursor.y = @minimum(self.cursor.y, self.rows - 1);
// TODO: reflow due to soft wrap
// If we're increasing height, then copy all rows (start at 0).

View File

@ -156,6 +156,7 @@ pub fn resize(self: *Terminal, alloc: Allocator, cols: usize, rows: usize) !void
// If we're making the screen smaller, dealloc the unused items.
// TODO: reflow
try self.screen.resize(alloc, rows, cols);
try self.secondary_screen.resize(alloc, rows, cols);
// Set our size
self.cols = cols;
@ -166,10 +167,6 @@ pub fn resize(self: *Terminal, alloc: Allocator, cols: usize, rows: usize) !void
.top = 0,
.bottom = rows - 1,
};
// Move our cursor
self.screen.cursor.x = @minimum(self.screen.cursor.x, self.cols - 1);
self.screen.cursor.y = @minimum(self.screen.cursor.y, self.rows - 1);
}
/// Return the current string value of the terminal. Newlines are