terminal: more dirty tracking

This commit is contained in:
Mitchell Hashimoto
2024-05-07 09:55:32 -07:00
parent 3cfce658c3
commit a1372a0efd

View File

@ -633,6 +633,9 @@ pub fn cursorDownScroll(self: *Screen) !void {
self.cursor.page_row = page_rac.row; self.cursor.page_row = page_rac.row;
self.cursor.page_cell = page_rac.cell; self.cursor.page_cell = page_rac.cell;
// Our new row is always dirty
self.cursorMarkDirty();
// Clear the new row so it gets our bg color. We only do this // Clear the new row so it gets our bg color. We only do this
// if we have a bg color at all. // if we have a bg color at all.
if (self.cursor.style.bg_color != .none) { if (self.cursor.style.bg_color != .none) {
@ -2889,6 +2892,7 @@ test "Screen: cursorAbsolute across pages preserves style" {
try testing.expect(styleval.flags.bold); try testing.expect(styleval.flags.bold);
} }
} }
test "Screen: scrolling" { test "Screen: scrolling" {
const testing = std.testing; const testing = std.testing;
const alloc = testing.allocator; const alloc = testing.allocator;
@ -2967,6 +2971,12 @@ test "Screen: scrolling with a single-row screen with scrollback" {
try testing.expectEqualStrings("", contents); try testing.expectEqualStrings("", contents);
} }
// Active should be dirty
try testing.expect(s.pages.isDirty(.{ .active = .{ .x = 0, .y = 0 } }));
// Our scrollback should not be dirty
try testing.expect(!s.pages.isDirty(.{ .screen = .{ .x = 0, .y = 0 } }));
s.scroll(.{ .delta_row = -1 }); s.scroll(.{ .delta_row = -1 });
{ {
const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} }); const contents = try s.dumpStringAlloc(alloc, .{ .viewport = .{} });