terminal/new: screen resize no reflow less rows

This commit is contained in:
Mitchell Hashimoto
2024-02-29 22:28:14 -08:00
parent df1c935a3a
commit baa3903d22
2 changed files with 20 additions and 20 deletions

View File

@ -363,6 +363,7 @@ pub const Resize = struct {
/// TODO: docs /// TODO: docs
pub fn resize(self: *PageList, opts: Resize) !void { pub fn resize(self: *PageList, opts: Resize) !void {
if (!opts.reflow) return try self.resizeWithoutReflow(opts); if (!opts.reflow) return try self.resizeWithoutReflow(opts);
@panic("TODO: resize with text reflow");
} }
fn resizeWithoutReflow(self: *PageList, opts: Resize) !void { fn resizeWithoutReflow(self: *PageList, opts: Resize) !void {

View File

@ -584,7 +584,7 @@ pub fn resize(
// If we have the same number of columns, text can't possibly // If we have the same number of columns, text can't possibly
// reflow in any way, so we do the quicker thing and do a resize // reflow in any way, so we do the quicker thing and do a resize
// without reflow checks. // without reflow checks.
try self.resizeWithoutReflow(rows, cols); try self.resizeWithoutReflow(cols, rows);
return; return;
} }
@ -596,11 +596,10 @@ pub fn resize(
/// with zeros. /// with zeros.
pub fn resizeWithoutReflow( pub fn resizeWithoutReflow(
self: *Screen, self: *Screen,
rows: size.CellCountInt,
cols: size.CellCountInt, cols: size.CellCountInt,
rows: size.CellCountInt,
) !void { ) !void {
// If we're resizing to the same size, do nothing. try self.pages.resize(.{ .rows = rows, .cols = cols, .reflow = false });
if (self.pages.cols == cols and self.pages.rows == rows) return;
} }
/// Set a style attribute for the current cursor. /// Set a style attribute for the current cursor.
@ -1822,19 +1821,19 @@ test "Screen: resize (no reflow) more rows" {
} }
} }
// test "Screen: resize (no reflow) less rows" { test "Screen: resize (no reflow) less rows" {
// const testing = std.testing; const testing = std.testing;
// const alloc = testing.allocator; const alloc = testing.allocator;
//
// var s = try init(alloc, 10, 3, 0); var s = try init(alloc, 10, 3, 0);
// defer s.deinit(); defer s.deinit();
// const str = "1ABCD\n2EFGH\n3IJKL"; const str = "1ABCD\n2EFGH\n3IJKL";
// try s.testWriteString(str); try s.testWriteString(str);
// try s.resizeWithoutReflow(10, 2); try s.resizeWithoutReflow(10, 2);
//
// { {
// const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} }); const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
// defer alloc.free(contents); defer alloc.free(contents);
// try testing.expectEqualStrings("2EFGH\n3IJKL", contents); try testing.expectEqualStrings("2EFGH\n3IJKL", contents);
// } }
// } }