terminal: dirty tracking in more places, tests coverage

This commit is contained in:
Mitchell Hashimoto
2024-05-07 09:52:03 -07:00
parent a84314befe
commit 3cfce658c3
2 changed files with 25 additions and 0 deletions

View File

@ -2023,6 +2023,12 @@ pub fn eraseRow(
}
}
{
// Set all the rows as dirty in this page
var dirty = page.data.dirtyBitSet();
dirty.setRangeValue(.{ .start = pn.y, .end = page.data.size.rows }, true);
}
// We iterate through all of the following pages in order to move their
// rows up by 1 as well.
while (page.next) |next| {
@ -2054,6 +2060,10 @@ pub fn eraseRow(
fastmem.rotateOnce(Row, rows[0..page.data.size.rows]);
// Set all the rows as dirty
var dirty = page.data.dirtyBitSet();
dirty.setRangeValue(.{ .start = 0, .end = page.data.size.rows }, true);
// Our tracked pins for this page need to be updated.
// If the pin is in row 0 that means the corresponding row has
// been moved to the previous page. Otherwise, move it up by 1.

View File

@ -565,10 +565,17 @@ pub fn cursorDownScroll(self: *Screen) !void {
self.cursor.page_row,
self.cursor.page_pin.page.data.getCells(self.cursor.page_row),
);
var dirty = self.cursor.page_pin.page.data.dirtyBitSet();
dirty.set(0);
} else {
// eraseRow will shift everything below it up.
try self.pages.eraseRow(.{ .active = .{} });
// Note we don't need to mark anything dirty in this branch
// because eraseRow will mark all the rotated rows as dirty
// in the entire page.
// We need to move our cursor down one because eraseRows will
// preserve our pin directly and we're erasing one row.
const page_pin = self.cursor.page_pin.down(1).?;
@ -2909,6 +2916,11 @@ test "Screen: scrolling" {
}, cell.content.color_rgb);
}
// Everything is dirty because we have no scrollback
try testing.expect(s.pages.isDirty(.{ .active = .{ .x = 0, .y = 0 } }));
try testing.expect(s.pages.isDirty(.{ .active = .{ .x = 0, .y = 1 } }));
try testing.expect(s.pages.isDirty(.{ .active = .{ .x = 0, .y = 2 } }));
// Scrolling to the bottom does nothing
s.scroll(.{ .active = {} });
@ -2934,6 +2946,9 @@ test "Screen: scrolling with a single-row screen no scrollback" {
defer alloc.free(contents);
try testing.expectEqualStrings("", contents);
}
// Screen should be dirty
try testing.expect(s.pages.isDirty(.{ .active = .{ .x = 0, .y = 0 } }));
}
test "Screen: scrolling with a single-row screen with scrollback" {