mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
terminal/new: more screen tests
This commit is contained in:
@ -5414,6 +5414,7 @@ test "Screen: scrollRegionUp buffer wrap alternative with extra lines" {
|
||||
}
|
||||
}
|
||||
|
||||
// X
|
||||
test "Screen: clear history with no history" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
@ -5438,6 +5439,7 @@ test "Screen: clear history with no history" {
|
||||
}
|
||||
}
|
||||
|
||||
// X
|
||||
test "Screen: clear history" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
@ -5472,6 +5474,7 @@ test "Screen: clear history" {
|
||||
}
|
||||
}
|
||||
|
||||
// X
|
||||
test "Screen: clear above cursor" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
|
@ -1709,3 +1709,58 @@ test "Screen: clear history" {
|
||||
try testing.expectEqualStrings("4ABCD\n5EFGH\n6IJKL", contents);
|
||||
}
|
||||
}
|
||||
|
||||
test "Screen: clear above cursor" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
|
||||
var s = try init(alloc, 10, 10, 3);
|
||||
defer s.deinit();
|
||||
try s.testWriteString("4ABCD\n5EFGH\n6IJKL");
|
||||
s.clearRows(
|
||||
.{ .active = .{ .y = 0 } },
|
||||
.{ .active = .{ .y = s.cursor.y - 1 } },
|
||||
false,
|
||||
);
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("\n\n6IJKL", contents);
|
||||
}
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("\n\n6IJKL", contents);
|
||||
}
|
||||
|
||||
try testing.expectEqual(@as(usize, 5), s.cursor.x);
|
||||
try testing.expectEqual(@as(usize, 2), s.cursor.y);
|
||||
}
|
||||
|
||||
test "Screen: clear above cursor with history" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
|
||||
var s = try init(alloc, 10, 3, 3);
|
||||
defer s.deinit();
|
||||
try s.testWriteString("1ABCD\n2EFGH\n3IJKL\n");
|
||||
try s.testWriteString("4ABCD\n5EFGH\n6IJKL");
|
||||
s.clearRows(
|
||||
.{ .active = .{ .y = 0 } },
|
||||
.{ .active = .{ .y = s.cursor.y - 1 } },
|
||||
false,
|
||||
);
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("\n\n6IJKL", contents);
|
||||
}
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("1ABCD\n2EFGH\n3IJKL\n\n\n6IJKL", contents);
|
||||
}
|
||||
|
||||
try testing.expectEqual(@as(usize, 5), s.cursor.x);
|
||||
try testing.expectEqual(@as(usize, 2), s.cursor.y);
|
||||
}
|
||||
|
Reference in New Issue
Block a user