mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 16:26:08 +03:00
terminal/new: screen scrollClear tests
This commit is contained in:
@ -4174,6 +4174,7 @@ test "Screen: scrolling with scrollback available doesn't move selection" {
|
||||
}
|
||||
}
|
||||
|
||||
// X
|
||||
test "Screen: scroll and clear full screen" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
@ -4201,6 +4202,7 @@ test "Screen: scroll and clear full screen" {
|
||||
}
|
||||
}
|
||||
|
||||
// X
|
||||
test "Screen: scroll and clear partial screen" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
@ -4228,6 +4230,7 @@ test "Screen: scroll and clear partial screen" {
|
||||
}
|
||||
}
|
||||
|
||||
// X
|
||||
test "Screen: scroll and clear empty screen" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
@ -4238,6 +4241,7 @@ test "Screen: scroll and clear empty screen" {
|
||||
try testing.expectEqual(@as(usize, 0), s.viewport);
|
||||
}
|
||||
|
||||
// X
|
||||
test "Screen: scroll and clear ignore blank lines" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
|
@ -375,7 +375,7 @@ pub fn scroll(self: *Screen, behavior: Scroll) void {
|
||||
/// to be on top.
|
||||
pub fn scrollClear(self: *Screen) !void {
|
||||
try self.pages.scrollClear();
|
||||
self.cursorAbsolute(0, 0);
|
||||
self.cursorReload();
|
||||
|
||||
// No matter what, scrolling marks our image state as dirty since
|
||||
// it could move placements. If there are no placements or no images
|
||||
@ -1287,3 +1287,119 @@ test "Screen: scrollback doesn't move viewport if not at bottom" {
|
||||
try testing.expectEqualStrings("2EFGH\n3IJKL\n4ABCD", contents);
|
||||
}
|
||||
}
|
||||
|
||||
test "Screen: scroll and clear full screen" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
|
||||
var s = try init(alloc, 10, 3, 5);
|
||||
defer s.deinit();
|
||||
try s.testWriteString("1ABCD\n2EFGH\n3IJKL");
|
||||
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("1ABCD\n2EFGH\n3IJKL", contents);
|
||||
}
|
||||
|
||||
try s.scrollClear();
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("", contents);
|
||||
}
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("1ABCD\n2EFGH\n3IJKL", contents);
|
||||
}
|
||||
}
|
||||
|
||||
test "Screen: scroll and clear partial screen" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
|
||||
var s = try init(alloc, 10, 3, 5);
|
||||
defer s.deinit();
|
||||
try s.testWriteString("1ABCD\n2EFGH");
|
||||
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("1ABCD\n2EFGH", contents);
|
||||
}
|
||||
|
||||
try s.scrollClear();
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("", contents);
|
||||
}
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("1ABCD\n2EFGH", contents);
|
||||
}
|
||||
}
|
||||
|
||||
test "Screen: scroll and clear empty screen" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
|
||||
var s = try init(alloc, 10, 3, 5);
|
||||
defer s.deinit();
|
||||
try s.scrollClear();
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("", contents);
|
||||
}
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("", contents);
|
||||
}
|
||||
}
|
||||
|
||||
test "Screen: scroll and clear ignore blank lines" {
|
||||
const testing = std.testing;
|
||||
const alloc = testing.allocator;
|
||||
|
||||
var s = try init(alloc, 10, 3, 10);
|
||||
defer s.deinit();
|
||||
try s.testWriteString("1ABCD\n2EFGH");
|
||||
try s.scrollClear();
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("", contents);
|
||||
}
|
||||
|
||||
// Move back to top-left
|
||||
s.cursorAbsolute(0, 0);
|
||||
|
||||
// Write and clear
|
||||
try s.testWriteString("3ABCD\n");
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .active = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("3ABCD", contents);
|
||||
}
|
||||
|
||||
try s.scrollClear();
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("", contents);
|
||||
}
|
||||
|
||||
// Move back to top-left
|
||||
s.cursorAbsolute(0, 0);
|
||||
try s.testWriteString("X");
|
||||
|
||||
{
|
||||
const contents = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
|
||||
defer alloc.free(contents);
|
||||
try testing.expectEqualStrings("1ABCD\n2EFGH\n3ABCD\nX", contents);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user