mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
test(terminal/Screen): clearRows with protected cells
This commit is contained in:
@ -2219,6 +2219,7 @@ pub fn testWriteString(self: *Screen, text: []const u8) !void {
|
|||||||
.content_tag = .codepoint,
|
.content_tag = .codepoint,
|
||||||
.content = .{ .codepoint = c },
|
.content = .{ .codepoint = c },
|
||||||
.style_id = self.cursor.style_id,
|
.style_id = self.cursor.style_id,
|
||||||
|
.protected = self.cursor.protected,
|
||||||
};
|
};
|
||||||
|
|
||||||
// If we have a ref-counted style, increase.
|
// If we have a ref-counted style, increase.
|
||||||
@ -2235,6 +2236,7 @@ pub fn testWriteString(self: *Screen, text: []const u8) !void {
|
|||||||
.content_tag = .codepoint,
|
.content_tag = .codepoint,
|
||||||
.content = .{ .codepoint = 0 },
|
.content = .{ .codepoint = 0 },
|
||||||
.wide = .spacer_head,
|
.wide = .spacer_head,
|
||||||
|
.protected = self.cursor.protected,
|
||||||
};
|
};
|
||||||
|
|
||||||
self.cursor.page_row.wrap = true;
|
self.cursor.page_row.wrap = true;
|
||||||
@ -2249,6 +2251,7 @@ pub fn testWriteString(self: *Screen, text: []const u8) !void {
|
|||||||
.content = .{ .codepoint = c },
|
.content = .{ .codepoint = c },
|
||||||
.style_id = self.cursor.style_id,
|
.style_id = self.cursor.style_id,
|
||||||
.wide = .wide,
|
.wide = .wide,
|
||||||
|
.protected = self.cursor.protected,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Write our tail
|
// Write our tail
|
||||||
@ -2257,6 +2260,7 @@ pub fn testWriteString(self: *Screen, text: []const u8) !void {
|
|||||||
.content_tag = .codepoint,
|
.content_tag = .codepoint,
|
||||||
.content = .{ .codepoint = 0 },
|
.content = .{ .codepoint = 0 },
|
||||||
.wide = .spacer_tail,
|
.wide = .spacer_tail,
|
||||||
|
.protected = self.cursor.protected,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -2537,6 +2541,34 @@ test "Screen clearRows active styled line" {
|
|||||||
try testing.expectEqualStrings("", str);
|
try testing.expectEqualStrings("", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "Screen clearRows protected" {
|
||||||
|
const testing = std.testing;
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
|
||||||
|
var s = try Screen.init(alloc, 80, 24, 1000);
|
||||||
|
defer s.deinit();
|
||||||
|
|
||||||
|
try s.testWriteString("UNPROTECTED");
|
||||||
|
s.cursor.protected = true;
|
||||||
|
try s.testWriteString("PROTECTED");
|
||||||
|
s.cursor.protected = false;
|
||||||
|
try s.testWriteString("UNPROTECTED");
|
||||||
|
try s.testWriteString("\n");
|
||||||
|
s.cursor.protected = true;
|
||||||
|
try s.testWriteString("PROTECTED");
|
||||||
|
s.cursor.protected = false;
|
||||||
|
try s.testWriteString("UNPROTECTED");
|
||||||
|
s.cursor.protected = true;
|
||||||
|
try s.testWriteString("PROTECTED");
|
||||||
|
s.cursor.protected = false;
|
||||||
|
|
||||||
|
s.clearRows(.{ .active = .{} }, null, true);
|
||||||
|
|
||||||
|
const str = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
|
||||||
|
defer alloc.free(str);
|
||||||
|
try testing.expectEqualStrings(" PROTECTED\nPROTECTED PROTECTED", str);
|
||||||
|
}
|
||||||
|
|
||||||
test "Screen eraseRows history" {
|
test "Screen eraseRows history" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
|
Reference in New Issue
Block a user