diff options
Diffstat (limited to 'core/views.zig')
| -rw-r--r-- | core/views.zig | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/core/views.zig b/core/views.zig index ee061964..a8bf8e60 100644 --- a/core/views.zig +++ b/core/views.zig @@ -579,25 +579,25 @@ test "each view has its own cursor and scroll, and an edit in one is in the othe const text = try numbered(gpa, 200); defer gpa.free(text); const pane = try p.setTestFile(text); - try testing.expectEqual(@as(?u8, 1), p.openView()); + try testing.expectEqual(@as(?View.Id, .at(1)), p.openView()); cursorTo(p, pane, 119); const scrolled = pane.file.?.scroll; try testing.expect(scrolled > 0); // The other view is where the session was when it came. - p.toView(1); + p.toView(.at(1)); try testing.expectEqual(@as(i32, 0), pane.body.cur_row); try testing.expectEqual(@as(usize, 0), pane.file.?.scroll); typeKeys(p, "ix"); escape(p); try testing.expectEqual(Text.Mode.normal, pane.body.mode); - p.toView(0); + p.toView(.at(0)); try testing.expectEqual(@as(i32, 119), pane.body.cur_row); try testing.expectEqual(scrolled, pane.file.?.scroll); try testing.expect(std.mem.startsWith(u8, pane.file.?.content, "xline 1\n")); // Its mode is its own: insert here leaves the other in normal. typeKeys(p, "i"); try testing.expectEqual(Text.Mode.insert, pane.body.mode); - p.toView(1); + p.toView(.at(1)); try testing.expectEqual(Text.Mode.normal, pane.body.mode); } @@ -614,7 +614,7 @@ test "each view has its own layout and focus over the same panes" { const made = p.view().active; try testing.expect(made != 0); try testing.expectEqual(ncol + 1, p.view().ncol); - p.toView(0); + p.toView(.at(0)); try testing.expectEqual(ncol, p.view().ncol); try testing.expectEqual(@as(usize, 0), p.view().active); try testing.expect(layout.findPane(p, made) == null); @@ -663,15 +663,15 @@ test "a terminal shown at two sizes takes the size of the view that typed into i p.update(.{ .key = .{ .cp = Key.right } }); try testing.expect(term.cols > small[0] and term.rows > small[1]); const big = .{ term.cols, term.rows }; - p.toView(0); + p.toView(.at(0)); p.sync(); try testing.expectEqual(big, .{ term.cols, term.rows }); p.update(.{ .key = .{ .cp = Key.right } }); try testing.expectEqual(small, .{ term.cols, term.rows }); // That view gone, the one left sizes it. p.toView(k); - p.closeView(0); - try testing.expectEqual(k, p.live); + p.closeView(.at(0)); + try testing.expectEqual(k.index(), p.live); try testing.expectEqual(big, .{ term.cols, term.rows }); } @@ -691,18 +691,18 @@ test "a view closing leaves the others as they were" { typeKeys(p, "xy"); p.toView(a); cursorTo(p, pane, 70); - p.toView(0); + p.toView(.at(0)); cursorTo(p, pane, 10); const ncol = p.view().ncol; // The live one closing: the session goes into another. p.toView(b); p.closeView(b); - try testing.expect(p.live != b); + try testing.expect(p.live != b.index()); try testing.expectEqual(@as(usize, 2), count(p)); p.toView(a); try testing.expectEqual(@as(i32, 70), pane.body.cur_row); - p.closeView(0); - try testing.expectEqual(a, p.live); + p.closeView(.at(0)); + try testing.expectEqual(a.index(), p.live); try testing.expectEqual(ncol, p.view().ncol); // The last stays. p.closeView(a); @@ -749,7 +749,7 @@ test "a client's view kept for its rejoin: through an Upgrade's dump, each clien defer p.deinit(); _ = try p.setTestFile("one\ntwo\n"); // Two clients, each a pane of its own in its own view. - const ks: [2]u8 = .{ p.openView().?, p.openView().? }; + const ks: [2]View.Id = .{ p.openView().?, p.openView().? }; var made: [2]usize = undefined; for (ks, &made) |k, *m| { p.toView(k); @@ -767,7 +767,7 @@ test "a client's view kept for its rejoin: through an Upgrade's dump, each clien const q = try pardes.dump.load(gpa, opts, bytes, null); defer q.deinit(); for (ks, made, 0..) |k, m, i| { - try testing.expect(isAway(q, k)); + try testing.expect(isAway(q, k.index())); try testing.expect(q.rejoinView(k)); q.toView(k); try testing.expectEqual(m, q.view().active); @@ -776,10 +776,10 @@ test "a client's view kept for its rejoin: through an Upgrade's dump, each clien } try testing.expect(!q.rejoinView(ks[0])); // A client that never comes back: its view goes when a join has no room. - p.toView(0); - try testing.expectEqual(@as(?u8, 3), p.openView()); + p.toView(.at(0)); + try testing.expectEqual(@as(?View.Id, .at(3)), p.openView()); try testing.expectEqual(ks[0], p.openView()); - try testing.expect(!isAway(p, ks[0]) and isAway(p, ks[1])); + try testing.expect(!isAway(p, ks[0].index()) and isAway(p, ks[1].index())); } test "drawing another view leaves the live one as it was, to the digest" { @@ -793,10 +793,10 @@ test "drawing another view leaves the live one as it was, to the digest" { p.toView(k); cursorTo(p, pane, 60); typeKeys(p, "dd"); - p.toView(0); + p.toView(.at(0)); cursorTo(p, pane, 95); const before = pardes.walk.digest(Pardes, p); - _ = try drawOne(p, k, .{ .ctx = null, .f = null }); + _ = try drawOne(p, k.index(), .{ .ctx = null, .f = null }); try testing.expectEqual(@as(u8, 0), p.live); try testing.expectEqual(before, pardes.walk.digest(Pardes, p)); p.toView(k); @@ -812,9 +812,9 @@ test "a view drawn while another is live keeps its own cursors" { p.toView(k); p.update(.{ .key = .{ .cp = 'C', .text = "C" } }); try testing.expectEqual(@as(u16, 1), pane.body.nsel); - p.toView(0); + p.toView(.at(0)); const before = pardes.walk.digest(Pardes, p); - _ = try drawOne(p, k, .{ .ctx = null, .f = null }); + _ = try drawOne(p, k.index(), .{ .ctx = null, .f = null }); try testing.expectEqual(before, pardes.walk.digest(Pardes, p)); p.toView(k); try testing.expectEqual(@as(u16, 1), pane.body.nsel); @@ -831,7 +831,7 @@ test "a view not live keeps its place in a text another view edits" { p.toView(k); cursorTo(p, pane, 100); const scrolled = pane.file.?.scroll; - p.toView(0); + p.toView(.at(0)); // Three lines put above it, one taken below it. typeKeys(p, "xyppp"); cursorTo(p, pane, 150); @@ -862,7 +862,7 @@ test "a terminal shown in a view shorter than it keeps its cursor in sight" { p.update(.{ .output = .{ .pane = @intCast(id), .bytes = out.items } }); // Sized for the tall view, it fits there whole: nothing is passed over. try testing.expectEqual(@as(u16, 0), term.pan); - p.toView(0); + p.toView(.at(0)); p.sync(); try testing.expectEqual(rows, term.rows); try testing.expect(term.pan > 0); @@ -897,7 +897,7 @@ test "a session's dump keeps its views: loaded, each where it was; revived for o cursorTo(p, pane, 119); p.toView(k); p.update(.{ .command = "Newcol" }); - p.toView(0); + p.toView(.at(0)); p.toView(k); cursorTo(p, pane, 30); const ncol = p.view().ncol; @@ -910,7 +910,7 @@ test "a session's dump keeps its views: loaded, each where it was; revived for o defer gpa.free(again); try testing.expectEqualSlices(u8, bytes, again); const lp = loaded.panes[id].?; - loaded.toView(0); + loaded.toView(.at(0)); try testing.expectEqual(@as(i32, 119), lp.body.cur_row); try testing.expectEqual(ncol - 1, loaded.view().ncol); loaded.toView(k); @@ -923,7 +923,7 @@ test "a session's dump keeps its views: loaded, each where it was; revived for o try testing.expectEqual(@as(u8, 0), one.live); try testing.expectEqual(ncol, one.view().ncol); try testing.expectEqual(@as(i32, 30), one.panes[id].?.body.cur_row); - try testing.expectEqual(@as(?u8, 1), one.openView()); + try testing.expectEqual(@as(?View.Id, .at(1)), one.openView()); } test "a pane's id and a view's id are two types: neither is taken for the other, nor for an integer" { |
