diff options
Diffstat (limited to 'core/views.zig')
| -rw-r--r-- | core/views.zig | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/core/views.zig b/core/views.zig index a81e8430..3b238258 100644 --- a/core/views.zig +++ b/core/views.zig @@ -41,7 +41,7 @@ pub const away_kept_ns: u64 = 30 * std.time.ns_per_s; /// layout, which of its texts has the keyboard, how far it is scrolled (a /// terminal's history too), and what the view's step measured of it (its /// tag's rows, its bands). -const pane_fields = [_][:0]const u8{ "focus", "vweight", "collapsed", "docked_to", "hscroll", "tag_scroll", "tag_top", "tag_rows", "band_rows", "view", "layers", "notices", "pan", "follow_scroll", "scrolled_to" }; +const pane_fields = [_][:0]const u8{ "focus", "vweight", "collapsed", "docked_to", "hscroll", "tag_scroll", "tag_top", "tag_rows", "view", "layers", "notices", "pan", "follow_scroll", "scrolled_to" }; /// The body's: its cursor, selections and mode. Its undo stays the pane's. const body_fields = [_][:0]const u8{ "mode", "cur_pinned", "cur_row", "cur_col", "vsel", "sels", "nsel", "select", "sticky_col", "restore_cursor", "last_edit", "reg_wait", "normal", "find_op", "find_ch" }; @@ -56,7 +56,6 @@ pub const PaneView = struct { tag_scroll: u16 = 0, tag_top: u16 = 0, tag_rows: u16 = 1, - band_rows: u16 = 0, view: Pane.SessionView = .{}, layers: File.Layers = .{}, notices: Pane.Notices = .{}, @@ -581,18 +580,20 @@ 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 as dumped, 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 over its body as dumped, its tag's rows its rows at rest" { const gpa = std.testing.allocator; const dump = @import("dump.zig"); const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 30 }); defer p.deinit(); const pane = try p.setTestFile("one\n"); - // SPC's level unrolled in view 0: its band's rows in the tag's. + p.sync(); + const rest = pane.tag_rows; + // SPC's level unrolled in view 0: its band over the body's top rows. p.update(.{ .key = .{ .cp = ' ' } }); p.update(.{ .key = .{ .cp = Key.down } }); p.sync(); - const band = pane.band_rows; - try testing.expect(band > 0 and pane.tag_rows - band <= pardes.MAX_TAG_ROWS and pane.tag_rows > pardes.MAX_TAG_ROWS); + const covered = pane.view.covered; + try testing.expect(covered > 0 and pane.tag_rows == rest); // Another view live, view 0 parked, as a client's is when a join's // (a replica's rollback's) dump is made. const k = p.openView().?; @@ -603,15 +604,15 @@ test "a view not live with its band open, dumped and loaded, draws before its ne defer q.deinit(); try testing.expectEqual(pardes.walk.digest(Pardes, p), pardes.walk.digest(Pardes, q)); // View 0 drawn with no step first (a client's draw, a pump's other - // views): its band as it was, the tag's own rows under the bound. - try testing.expectEqual(band, q.panes[0].?.pv[0].band_rows); + // views): its band over its body as it was. + try testing.expectEqual(covered, q.panes[0].?.pv[0].view.covered); _ = try drawOne(q, 0, .{ .ctx = null, .f = null }); - // The bound itself: a share whose band's rows are not counted. - q.panes[0].?.pv[0].band_rows = 0; + // A share whose covered rows are not counted draws the same band. + q.panes[0].?.pv[0].view.covered = 0; _ = try drawOne(q, 0, .{ .ctx = null, .f = null }); } -test "a band its sync held short under a head of two rows, dumped and loaded: its rows are the never-loaded session's, and so is the next layout" { +test "a picker's band in a short column, 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 = 12 }); @@ -635,15 +636,17 @@ test "a band its sync held short under a head of two rows, dumped and loaded: it p.stream.engine = .walk; pardes.Pick.open(p, host, .find, "", "", ""); p.sync(); - 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 at = pardes.Band.covered(p, pane, host); + try testing.expect(at.band > 0 and at.band < pardes.Band.takes(p, host)); + try testing.expect(at.text >= 2); const bytes = try dump.byteDump(p); defer gpa.free(bytes); const q = try dump.load(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }, bytes, null); defer q.deinit(); - try testing.expectEqual(pane.band_rows, q.panes[host].?.band_rows); + try testing.expectEqual(pane.view.covered, q.panes[host].?.view.covered); + try testing.expectEqual(pane.tag_rows, q.panes[host].?.tag_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). + // floorRows, from the state alone). 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]); |
