terminal: scrollDown dirty tests

This commit is contained in:
Mitchell Hashimoto
2024-04-16 11:03:39 -07:00
parent 58aa4cc10b
commit bd1a7d3db1

View File

@ -1594,6 +1594,10 @@ pub fn deleteLines(self: *Terminal, count_req: usize) void {
const src: *Row = src_rac.row;
const dst: *Row = dst_rac.row;
// Mark both our src/dst as dirty
p.markDirty();
src_p.markDirty();
self.rowWillBeShifted(&src_p.page.data, src);
self.rowWillBeShifted(&p.page.data, dst);
@ -1659,6 +1663,9 @@ pub fn deleteLines(self: *Terminal, count_req: usize) void {
while (it.next()) |p| {
const row: *Row = p.rowAndCell().row;
// This row is now dirty
p.markDirty();
// Clear the src row.
const page = &p.page.data;
const cells = page.getCells(row);
@ -4818,11 +4825,17 @@ test "Terminal: scrollUp simple" {
try t.linefeed();
try t.printString("GHI");
t.setCursorPos(2, 2);
const cursor = t.screen.cursor;
t.clearDirty();
t.scrollUp(1);
try testing.expectEqual(cursor.x, t.screen.cursor.x);
try testing.expectEqual(cursor.y, t.screen.cursor.y);
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);
@ -4844,8 +4857,14 @@ test "Terminal: scrollUp top/bottom scroll region" {
try t.printString("GHI");
t.setTopAndBottomMargin(2, 3);
t.setCursorPos(1, 1);
t.clearDirty();
t.scrollUp(1);
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);
@ -4868,11 +4887,17 @@ test "Terminal: scrollUp left/right scroll region" {
t.scrolling_region.left = 1;
t.scrolling_region.right = 3;
t.setCursorPos(2, 2);
const cursor = t.screen.cursor;
t.clearDirty();
t.scrollUp(1);
try testing.expectEqual(cursor.x, t.screen.cursor.x);
try testing.expectEqual(cursor.y, t.screen.cursor.y);
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);
@ -4910,8 +4935,13 @@ test "Terminal: scrollUp full top/bottom region" {
t.setCursorPos(5, 1);
try t.printString("ABCDE");
t.setTopAndBottomMargin(2, 5);
t.clearDirty();
t.scrollUp(4);
try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 0 } }));
try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 1 } }));
{
const str = try t.plainString(testing.allocator);
defer testing.allocator.free(str);
@ -4930,8 +4960,13 @@ test "Terminal: scrollUp full top/bottomleft/right scroll region" {
t.modes.set(.enable_left_and_right_margin, true);
t.setTopAndBottomMargin(2, 5);
t.setLeftAndRightMargin(2, 4);
t.clearDirty();
t.scrollUp(4);
try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 0 } }));
for (1..5) |y| try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = y } }));
{
const str = try t.plainString(testing.allocator);
defer testing.allocator.free(str);