mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
terminal/new: start porting resize tests, bugs
This commit is contained in:
@ -6353,6 +6353,7 @@ test "Screen: resize (no reflow) more rows with soft wrapping" {
|
||||
}
|
||||
}
|
||||
|
||||
// X
|
||||
test "Screen: resize more rows no scrollback" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
@ -6379,6 +6380,7 @@ test "Screen: resize more rows no scrollback" {
|
||||
}
|
||||
}
|
||||
|
||||
// X
|
||||
test "Screen: resize more rows with empty scrollback" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
@ -6405,6 +6407,7 @@ test "Screen: resize more rows with empty scrollback" {
|
||||
}
|
||||
}
|
||||
|
||||
// X
|
||||
test "Screen: resize more rows with populated scrollback" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
|
@ -599,18 +599,14 @@ pub fn resize(
|
||||
// No matter what we mark our image state as dirty
|
||||
self.kitty_images.dirty = true;
|
||||
|
||||
// We grow rows after cols so that we can do our unwrapping/reflow
|
||||
// before we do a no-reflow grow.
|
||||
//
|
||||
// If our rows got smaller, we trim the scrollback. We do this after
|
||||
// handling cols growing so that we can save as many lines as we can.
|
||||
// We do it before cols shrinking so we can save compute on that operation.
|
||||
if (rows != self.pages.rows) {
|
||||
try self.resizeWithoutReflow(rows, self.cols);
|
||||
assert(self.pages.rows == rows);
|
||||
}
|
||||
// Resize our pages
|
||||
try self.pages.resize(.{
|
||||
.rows = rows,
|
||||
.cols = cols,
|
||||
.reflow = true,
|
||||
});
|
||||
|
||||
@panic("TODO");
|
||||
// TODO: cursor
|
||||
}
|
||||
|
||||
/// Resize the screen without any reflow. In this mode, columns/rows will
|
||||
@ -2060,6 +2056,106 @@ test "Screen: resize (no reflow) more rows with soft wrapping" {
|
||||
}
|
||||
}
|
||||
|
||||
test "Screen: resize more rows no scrollback" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
|
||||
var s = try init(alloc, 5, 3, 0);
|
||||
defer s.deinit();
|
||||
const str = "1ABCD\n2EFGH\n3IJKL";
|
||||
try s.testWriteString(str);
|
||||
const cursor = s.cursor;
|
||||
try s.resize(5, 10);
|
||||
|
||||
// Cursor should not move
|
||||
try testing.expectEqual(cursor.x, s.cursor.x);
|
||||
try testing.expectEqual(cursor.y, s.cursor.y);
|
||||
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings(str, contents);
|
||||
}
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings(str, contents);
|
||||
}
|
||||
}
|
||||
|
||||
test "Screen: resize more rows with empty scrollback" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
|
||||
var s = try init(alloc, 5, 3, 10);
|
||||
defer s.deinit();
|
||||
const str = "1ABCD\n2EFGH\n3IJKL";
|
||||
try s.testWriteString(str);
|
||||
const cursor = s.cursor;
|
||||
try s.resize(5, 10);
|
||||
|
||||
// Cursor should not move
|
||||
try testing.expectEqual(cursor.x, s.cursor.x);
|
||||
try testing.expectEqual(cursor.y, s.cursor.y);
|
||||
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings(str, contents);
|
||||
}
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings(str, contents);
|
||||
}
|
||||
}
|
||||
|
||||
test "Screen: resize more rows with populated scrollback" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
|
||||
var s = try init(alloc, 5, 3, 5);
|
||||
defer s.deinit();
|
||||
const str = "1ABCD\n2EFGH\n3IJKL\n4ABCD\n5EFGH";
|
||||
try s.testWriteString(str);
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||
defer alloc.free(contents);
|
||||
const expected = "3IJKL\n4ABCD\n5EFGH";
|
||||
try testing.expectEqualStrings(expected, contents);
|
||||
}
|
||||
|
||||
// Set our cursor to be on the "4"
|
||||
s.cursorAbsolute(0, 1);
|
||||
{
|
||||
const list_cell = s.pages.getCell(.{ .active = .{
|
||||
.x = s.cursor.x,
|
||||
.y = s.cursor.y,
|
||||
} }).?;
|
||||
try testing.expectEqual(@as(u21, '4'), list_cell.cell.content.codepoint);
|
||||
}
|
||||
|
||||
// Resize
|
||||
try s.resize(5, 10);
|
||||
|
||||
// Cursor should still be on the "4"
|
||||
// TODO
|
||||
// {
|
||||
// const list_cell = s.pages.getCell(.{ .active = .{
|
||||
// .x = s.cursor.x,
|
||||
// .y = s.cursor.y,
|
||||
// } }).?;
|
||||
// try testing.expectEqual(@as(u21, '4'), list_cell.cell.content.codepoint);
|
||||
// }
|
||||
|
||||
// {
|
||||
// const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||
// defer alloc.free(contents);
|
||||
// const expected = "3IJKL\n4ABCD\n5EFGH";
|
||||
// try testing.expectEqualStrings(expected, contents);
|
||||
// }
|
||||
}
|
||||
|
||||
// test "Screen: resize more cols no reflow" {
|
||||
// const testing = std.testing;
|
||||
// const alloc = testing.allocator;
|
||||
|
Reference in New Issue
Block a user