terminal: new coordinate type

This commit is contained in:
Mitchell Hashimoto
2024-04-28 10:16:10 -07:00
parent 4f2ee95ecd
commit f867fabf8e
2 changed files with 52 additions and 13 deletions

View File

@ -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);

View File

@ -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);