terminal: more dirty tests

This commit is contained in:
Mitchell Hashimoto
2024-04-16 14:57:44 -07:00
parent cfcd16354a
commit fb25f5cea1
2 changed files with 21 additions and 0 deletions

View File

@ -809,6 +809,10 @@ pub fn clearRows(
var it = self.pages.pageIterator(.right_down, tl, bl);
while (it.next()) |chunk| {
// Mark everything in this chunk as dirty
var dirty = chunk.page.data.dirtyBitSet();
dirty.setRangeValue(.{ .start = chunk.start, .end = chunk.end }, true);
for (chunk.rows()) |*row| {
const cells_offset = row.cells;
const cells_multi: [*]Cell = row.cells.ptr(chunk.page.data.memory);
@ -2508,6 +2512,7 @@ test "Screen clearRows active one line" {
try s.testWriteString("hello, world");
s.clearRows(.{ .active = .{} }, null, false);
try testing.expect(s.pages.isDirty(.{ .active = .{ .x = 0, .y = 0 } }));
const str = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
defer alloc.free(str);
try testing.expectEqualStrings("", str);
@ -2522,6 +2527,8 @@ test "Screen clearRows active multi line" {
try s.testWriteString("hello\nworld");
s.clearRows(.{ .active = .{} }, null, false);
try testing.expect(s.pages.isDirty(.{ .active = .{ .x = 0, .y = 0 } }));
try testing.expect(s.pages.isDirty(.{ .active = .{ .x = 0, .y = 1 } }));
const str = try s.dumpStringAlloc(alloc, .{ .screen = .{} });
defer alloc.free(str);
try testing.expectEqualStrings("", str);

View File

@ -8662,8 +8662,14 @@ test "Terminal: eraseDisplay simple erase below" {
try t.linefeed();
for ("GHI") |c| try t.print(c);
t.setCursorPos(2, 2);
t.clearDirty();
t.eraseDisplay(.below, false);
try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 0 } }));
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 1 } }));
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 2 } }));
{
const str = try t.plainString(testing.allocator);
defer testing.allocator.free(str);
@ -8840,7 +8846,12 @@ test "Terminal: eraseDisplay simple erase above" {
try t.linefeed();
for ("GHI") |c| try t.print(c);
t.setCursorPos(2, 2);
t.clearDirty();
t.eraseDisplay(.above, false);
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 0 } }));
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 1 } }));
try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 2 } }));
{
const str = try t.plainString(testing.allocator);
@ -9018,7 +9029,10 @@ test "Terminal: eraseDisplay protected complete" {
t.setProtectedMode(.dec);
try t.print('X');
t.setCursorPos(t.screen.cursor.y + 1, 4);
t.clearDirty();
t.eraseDisplay(.complete, true);
for (0..t.rows) |y| try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = y } }));
{
const str = try t.plainString(testing.allocator);