mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 09:16:11 +03:00
terminal/new: port more screen resize tests
This commit is contained in:
@ -6475,6 +6475,7 @@ test "Screen: resize more rows and cols with wrapping" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// X
|
||||||
test "Screen: resize more cols no reflow" {
|
test "Screen: resize more cols no reflow" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
@ -6501,6 +6502,7 @@ test "Screen: resize more cols no reflow" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// X
|
||||||
// https://github.com/mitchellh/ghostty/issues/272#issuecomment-1676038963
|
// https://github.com/mitchellh/ghostty/issues/272#issuecomment-1676038963
|
||||||
test "Screen: resize more cols perfect split" {
|
test "Screen: resize more cols perfect split" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
@ -6513,6 +6515,7 @@ test "Screen: resize more cols perfect split" {
|
|||||||
try s.resize(3, 10);
|
try s.resize(3, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// X
|
||||||
// https://github.com/mitchellh/ghostty/issues/1159
|
// https://github.com/mitchellh/ghostty/issues/1159
|
||||||
test "Screen: resize (no reflow) more cols with scrollback scrolled up" {
|
test "Screen: resize (no reflow) more cols with scrollback scrolled up" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
|
@ -599,14 +599,23 @@ pub fn resize(
|
|||||||
// No matter what we mark our image state as dirty
|
// No matter what we mark our image state as dirty
|
||||||
self.kitty_images.dirty = true;
|
self.kitty_images.dirty = true;
|
||||||
|
|
||||||
// Resize our pages
|
var cursor: PageList.Resize.Cursor = .{
|
||||||
|
.x = self.cursor.x,
|
||||||
|
.y = self.cursor.y,
|
||||||
|
};
|
||||||
|
|
||||||
try self.pages.resize(.{
|
try self.pages.resize(.{
|
||||||
.rows = rows,
|
.rows = rows,
|
||||||
.cols = cols,
|
.cols = cols,
|
||||||
.reflow = true,
|
.reflow = true,
|
||||||
|
.cursor = &cursor,
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: cursor
|
if (cursor.x != self.cursor.x or cursor.y != self.cursor.y) {
|
||||||
|
self.cursor.x = cursor.x;
|
||||||
|
self.cursor.y = cursor.y;
|
||||||
|
self.cursorReload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resize the screen without any reflow. In this mode, columns/rows will
|
/// Resize the screen without any reflow. In this mode, columns/rows will
|
||||||
@ -629,9 +638,11 @@ pub fn resizeWithoutReflow(
|
|||||||
.cursor = &cursor,
|
.cursor = &cursor,
|
||||||
});
|
});
|
||||||
|
|
||||||
self.cursor.x = cursor.x;
|
if (cursor.x != self.cursor.x or cursor.y != self.cursor.y) {
|
||||||
self.cursor.y = cursor.y;
|
self.cursor.x = cursor.x;
|
||||||
self.cursorReload();
|
self.cursor.y = cursor.y;
|
||||||
|
self.cursorReload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set a style attribute for the current cursor.
|
/// Set a style attribute for the current cursor.
|
||||||
@ -2175,30 +2186,75 @@ test "Screen: resize more rows with populated scrollback" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// test "Screen: resize more cols no reflow" {
|
test "Screen: resize more cols no reflow" {
|
||||||
// const testing = std.testing;
|
const testing = std.testing;
|
||||||
// const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
//
|
|
||||||
// var s = try init(alloc, 5, 3, 0);
|
var s = try init(alloc, 5, 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);
|
||||||
//
|
|
||||||
// const cursor = s.cursor;
|
const cursor = s.cursor;
|
||||||
// try s.resize(10, 3);
|
try s.resize(10, 3);
|
||||||
//
|
|
||||||
// // Cursor should not move
|
// Cursor should not move
|
||||||
// try testing.expectEqual(cursor.x, s.cursor.x);
|
try testing.expectEqual(cursor.x, s.cursor.x);
|
||||||
// try testing.expectEqual(cursor.y, s.cursor.y);
|
try testing.expectEqual(cursor.y, s.cursor.y);
|
||||||
//
|
|
||||||
// {
|
{
|
||||||
// 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(str, contents);
|
try testing.expectEqualStrings(str, contents);
|
||||||
// }
|
}
|
||||||
// {
|
{
|
||||||
// const contents = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
|
const contents = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
|
||||||
// defer alloc.free(contents);
|
defer alloc.free(contents);
|
||||||
// try testing.expectEqualStrings(str, contents);
|
try testing.expectEqualStrings(str, contents);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
// https://github.com/mitchellh/ghostty/issues/272#issuecomment-1676038963
|
||||||
|
test "Screen: resize more cols perfect split" {
|
||||||
|
const testing = std.testing;
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
|
||||||
|
var s = try init(alloc, 5, 3, 0);
|
||||||
|
defer s.deinit();
|
||||||
|
const str = "1ABCD2EFGH3IJKL";
|
||||||
|
try s.testWriteString(str);
|
||||||
|
try s.resize(10, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/mitchellh/ghostty/issues/1159
|
||||||
|
test "Screen: resize (no reflow) more cols with scrollback scrolled up" {
|
||||||
|
const testing = std.testing;
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
|
||||||
|
var s = try init(alloc, 5, 3, 5);
|
||||||
|
defer s.deinit();
|
||||||
|
const str = "1\n2\n3\n4\n5\n6\n7\n8";
|
||||||
|
try s.testWriteString(str);
|
||||||
|
|
||||||
|
// Cursor at bottom
|
||||||
|
try testing.expectEqual(@as(size.CellCountInt, 1), s.cursor.x);
|
||||||
|
try testing.expectEqual(@as(size.CellCountInt, 2), s.cursor.y);
|
||||||
|
|
||||||
|
s.scroll(.{ .delta_row = -4 });
|
||||||
|
{
|
||||||
|
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||||
|
defer alloc.free(contents);
|
||||||
|
try testing.expectEqualStrings("2\n3\n4", contents);
|
||||||
|
}
|
||||||
|
|
||||||
|
try s.resize(8, 3);
|
||||||
|
{
|
||||||
|
const contents = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
|
||||||
|
defer alloc.free(contents);
|
||||||
|
try testing.expectEqualStrings(str, contents);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cursor remains at bottom
|
||||||
|
try testing.expectEqual(@as(size.CellCountInt, 1), s.cursor.x);
|
||||||
|
try testing.expectEqual(@as(size.CellCountInt, 2), s.cursor.y);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user