From f867fabf8e12ca6fd5dfe8142762aa08eb690784 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 28 Apr 2024 10:16:10 -0700 Subject: [PATCH] terminal: new coordinate type --- src/terminal/PageList.zig | 10 +++++-- src/terminal/Terminal.zig | 55 +++++++++++++++++++++++++++++++-------- 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/src/terminal/PageList.zig b/src/terminal/PageList.zig index 5a7dbf271..53533f8c1 100644 --- a/src/terminal/PageList.zig +++ b/src/terminal/PageList.zig @@ -4601,7 +4601,10 @@ test "PageList eraseRowBounded full rows single page" { // The erased rows should be dirty try testing.expect(!s.isDirty(.{ .active = .{ .x = 0, .y = 4 } })); - for (5..10) |y| try testing.expect(s.isDirty(.{ .active = .{ .x = 0, .y = y } })); + for (5..10) |y| try testing.expect(s.isDirty(.{ .active = .{ + .x = 0, + .y = @intCast(y), + } })); // Our pin should move to the first page try testing.expectEqual(s.pages.first.?, p_in.page); @@ -4662,7 +4665,10 @@ test "PageList eraseRowBounded full rows two pages" { // The erased rows should be dirty try testing.expect(!s.isDirty(.{ .active = .{ .x = 0, .y = 3 } })); - for (4..8) |y| try testing.expect(s.isDirty(.{ .active = .{ .x = 0, .y = y } })); + for (4..8) |y| try testing.expect(s.isDirty(.{ .active = .{ + .x = 0, + .y = @intCast(y), + } })); // In page in first page is shifted try testing.expectEqual(s.pages.last.?.prev.?, p_first.page); diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index b242e959c..b83b9ff99 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -4975,7 +4975,10 @@ test "Terminal: scrollUp full top/bottomleft/right scroll region" { 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 } })); + for (1..5) |y| try testing.expect(t.isDirty(.{ .active = .{ + .x = 0, + .y = @intCast(y), + } })); { const str = try t.plainString(testing.allocator); @@ -5004,7 +5007,10 @@ test "Terminal: scrollDown simple" { try testing.expectEqual(cursor.x, t.screen.cursor.x); try testing.expectEqual(cursor.y, t.screen.cursor.y); - for (0..5) |y| try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = y } })); + for (0..5) |y| try testing.expect(t.isDirty(.{ .active = .{ + .x = 0, + .y = @intCast(y), + } })); { const str = try t.plainString(testing.allocator); @@ -5068,7 +5074,10 @@ test "Terminal: scrollDown left/right scroll region" { try testing.expectEqual(cursor.x, t.screen.cursor.x); try testing.expectEqual(cursor.y, t.screen.cursor.y); - for (0..4) |y| try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = y } })); + for (0..4) |y| try testing.expect(t.isDirty(.{ .active = .{ + .x = 0, + .y = @intCast(y), + } })); { const str = try t.plainString(testing.allocator); @@ -5099,7 +5108,10 @@ test "Terminal: scrollDown outside of left/right scroll region" { try testing.expectEqual(cursor.x, t.screen.cursor.x); try testing.expectEqual(cursor.y, t.screen.cursor.y); - for (0..4) |y| try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = y } })); + for (0..4) |y| try testing.expect(t.isDirty(.{ .active = .{ + .x = 0, + .y = @intCast(y), + } })); { const str = try t.plainString(testing.allocator); @@ -5809,7 +5821,10 @@ test "Terminal: index bottom of primary screen with scroll region" { try t.index(); try t.print('X'); - for (0..4) |y| try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = y } })); + for (0..4) |y| try testing.expect(!t.isDirty(.{ .active = .{ + .x = 0, + .y = @intCast(y), + } })); try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = 4 } })); { @@ -6579,7 +6594,10 @@ test "Terminal: deleteLines with scroll region, cursor outside of region" { t.clearDirty(); t.deleteLines(1); - for (0..4) |y| try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = y } })); + for (0..4) |y| try testing.expect(!t.isDirty(.{ .active = .{ + .x = 0, + .y = @intCast(y), + } })); { const str = try t.plainString(testing.allocator); @@ -6657,7 +6675,10 @@ test "Terminal: deleteLines left/right scroll region" { t.deleteLines(1); try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 0 } })); - for (1..3) |y| try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = y } })); + for (1..3) |y| try testing.expect(t.isDirty(.{ .active = .{ + .x = 0, + .y = @intCast(y), + } })); { const str = try t.plainString(testing.allocator); @@ -6685,7 +6706,10 @@ test "Terminal: deleteLines left/right scroll region from top" { t.clearDirty(); t.deleteLines(1); - for (0..3) |y| try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = y } })); + for (0..3) |y| try testing.expect(t.isDirty(.{ .active = .{ + .x = 0, + .y = @intCast(y), + } })); { const str = try t.plainString(testing.allocator); @@ -6714,7 +6738,10 @@ test "Terminal: deleteLines left/right scroll region high count" { t.deleteLines(100); try testing.expect(!t.isDirty(.{ .active = .{ .x = 0, .y = 0 } })); - for (1..3) |y| try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = y } })); + for (1..3) |y| try testing.expect(t.isDirty(.{ .active = .{ + .x = 0, + .y = @intCast(y), + } })); { const str = try t.plainString(testing.allocator); @@ -7078,7 +7105,10 @@ test "Terminal: DECALN" { try testing.expectEqual(@as(usize, 0), t.screen.cursor.y); try testing.expectEqual(@as(usize, 0), t.screen.cursor.x); - for (0..t.rows) |y| try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = y } })); + for (0..t.rows) |y| try testing.expect(t.isDirty(.{ .active = .{ + .x = 0, + .y = @intCast(y), + } })); { const str = try t.plainString(testing.allocator); @@ -9032,7 +9062,10 @@ test "Terminal: eraseDisplay protected complete" { t.clearDirty(); t.eraseDisplay(.complete, true); - for (0..t.rows) |y| try testing.expect(t.isDirty(.{ .active = .{ .x = 0, .y = y } })); + for (0..t.rows) |y| try testing.expect(t.isDirty(.{ .active = .{ + .x = 0, + .y = @intCast(y), + } })); { const str = try t.plainString(testing.allocator);