diff options
Diffstat (limited to 'core/views.zig')
| -rw-r--r-- | core/views.zig | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/core/views.zig b/core/views.zig index 7bf30aa0..02628e63 100644 --- a/core/views.zig +++ b/core/views.zig @@ -74,7 +74,7 @@ pub const PaneView = struct { /// In a dump (`Shares`): what a pane's step works out again. Its `view` /// is dumped: the step after `unpark` reads it before it syncs. - pub const replica = .{ .derived = .{ "notices", "pan", "band_rows" } }; + pub const replica = .{ .derived = .{ "notices", "pan" } }; }; /// The panes' shares of a view not live, as a session's dump keeps them @@ -171,24 +171,6 @@ pub fn undumped(p: *Pardes, others: []const Shares) void { } } -/// After a load: each view's band rows (derived: never dumped nor in the -/// digest) made again from its own tag state as its last sync made them. -/// Its tag rows, which are dumped, count them, and a view drawn before its -/// next step (drawOne: a replica client's, a pump's other views) reads the -/// tag's own rows as their difference (draw.zig): with the band's rows -/// zeroed by the load, a band's became the tag's, past MAX_TAG_ROWS. -pub fn bandsLoaded(p: *Pardes) void { - for (0..max) |k| if (isOpen(p, @intCast(k))) within(p, @intCast(k), {}, bandsOf) catch {}; -} - -fn bandsOf(_: void, p: *Pardes) anyerror!void { - for (p.panes, 0..) |slot, id| if (slot) |pane| { - const rows = if (pane.collapsed or pardes.Band.over(pane)) 0 else @min(pardes.Band.takes(p, id), pane.tag_rows -| 1); - pane.band_rows = rows; - pane.pv[p.live].band_rows = rows; - }; -} - /// The views a dump before `Pardes.views` kept (`OldDumped`): each its /// share of the session into `views[k]`, the rest as `undumped`. What /// each view holds is the session's then; one refused is freed. @@ -599,7 +581,7 @@ pub fn within(p: *Pardes, k: u8, ctx: anytype, comptime f: fn (@TypeOf(ctx), *Pa const testing = std.testing; const Key = pardes.Key; -test "a view not live with its band open, dumped and loaded, draws before its next step: its band's rows made again from its state, its tag's rows never past MAX_TAG_ROWS" { +test "a view not live with its band open, dumped and loaded, draws before its next step: its band's rows as dumped, its tag's rows never past MAX_TAG_ROWS" { const gpa = std.testing.allocator; const dump = @import("dump.zig"); const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 30 }); @@ -629,6 +611,37 @@ test "a view not live with its band open, dumped and loaded, draws before its ne _ = try drawOne(q, 0, .{ .ctx = null, .f = null }); } +test "a band its sync held short under a tag of two rows, dumped and loaded: its rows are the never-loaded session's, and so is the next layout" { + const gpa = std.testing.allocator; + const dump = @import("dump.zig"); + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 18 }); + defer p.deinit(); + const pane = try p.setTestFile("one\n"); + const host = p.view().active; + p.newScratchBelow(host); + const low = p.view().active; + p.view().active = host; + p.sync(); + p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = Key.down } }); + // The column has not the rows: the band is held under what it wants, + // under a tag of two rows of its own. + try testing.expect(pane.band_rows > 0 and pane.band_rows < pardes.Band.takes(p, host)); + try testing.expect(pane.tag_rows - pane.band_rows >= 2); + const bytes = try dump.byteDump(p); + defer gpa.free(bytes); + const q = try dump.load(gpa, .{ .tty_only = true, .cols = 40, .rows = 18 }, bytes, null); + defer q.deinit(); + try testing.expectEqual(pane.band_rows, q.panes[host].?.band_rows); + // The next step lays the column out from the band's floor (layout + // floorRows: the tag's own rows are its rows less the band's). + p.update(.{ .resize = .{ .cols = 40, .rows = 40 } }); + q.update(.{ .resize = .{ .cols = 40, .rows = 40 } }); + try testing.expectEqual(p.view().rects[host], q.view().rects[host]); + try testing.expectEqual(p.view().rects[low], q.view().rects[low]); + try testing.expectEqual(pardes.walk.digest(Pardes, p), pardes.walk.digest(Pardes, q)); +} + fn typeKeys(p: *Pardes, text: []const u8) void { for (text) |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); } |
