diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 21:19:37 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 21:57:19 -0300 |
| commit | 8e1526a71a74447cbba9f5487ef72d9feccfc0ed (patch) | |
| tree | ca10fd5a4f2d2cffbb3a78299b4d6434395b56bf /core/Band.zig | |
| parent | 1e8787e0b2eb3eaa4991a5160f6e5c35ba6f132e (diff) | |
| download | pardes-8e1526a71a74447cbba9f5487ef72d9feccfc0ed.tar.gz pardes-8e1526a71a74447cbba9f5487ef72d9feccfc0ed.zip | |
Band, sync, draw, layout, mouse, File: the text stays put under the band: out of rest a tag keeps exactly its rows at rest, and its head's rows past them and the band under it are drawn over the top rows of its body, which never moves, wraps or resizes for them (UX DESIGN I1, on the user's "the other editors when there's new ui on top of the text it doesn't scroll ... I think we should do that, no?"); THE OLD WAY: the band pushed the body down (Pardes.sync grew `tag_rows` by `band_rows` and the head's rows), so every row of the text jumped by the band's height on SPC Down, Help, `:`, the registers, a rolled level of three rows, and back on Esc, while a terminal's and a kind's band was a second path drawn over its body (Band.over, Band.shownRows); THE CHANGE: Band.covered (from the state alone, as takes is) says where a tag out of rest is drawn: its head's rows, the band under them (as many as the pane has; a picker's keeping D6's body under it), and `over`, those past the tag's own rows; sync keeps the tag's rows at rest (the terminal special case is every pane's now) and puts `over` in the pane's view (SessionView.covered) for File.show; draw.render draws the host's tag and band after every body, one path for every pane, the grip's column beside the covered rows on the tag's ground, a caret under them hidden until rest; layout.floorRows borrows for a level, Help, `:` or the registers only the rows its head and band need (a picker and code actions keep D6's 60 % / 6 rows; a terminal's and a kind's size stay their user's); mouse.bandPoint gives a covered row to the band (a head's row over the body: B2/B3 on its word as on the tag's first row, B1 nothing); File.show counts the covered rows like the context rows, so what a state shows (a prompt's current hit, C-r's) is put in the rows left visible, a target already there not moved; TagState's rolled level of a terminal takes its three rows too (over the pty, which keeps its size); `band_rows` goes from Pane and PaneView (the dump: SessionView.covered and Pick.previewed come); W1'S READING (I1 is silent on a landing near a file's top): a picker's preview starts under its band (Pick.previewing: from the first place it shows in its landing pane, the band takes its rows from that body, as before), since Find lands on line 1 and a band over the body's top hid the file's first eleven lines and the landing line; before its first row, and after Esc, the pane's own text is where it was; the GUI's tag rule goes under the head's rows as under the band's (gui.zig paneDecor); TESTS (FIRST, where the old behaviour was asserted, inverted): Band.zig "SPC Down unrolls ... drawn over the top rows of the body, which stays where it was" (was "the body pushed down and never drawn over"), "out of rest the body stays where it was ..." (a rolled level, SPC Down, Help, `:`, the registers and a picker before it previews: every row of text under the rows drawn over it on its screen row at rest, the same first row, size and scroll; Esc leaves the body's rows as at rest), "a level's band covers what it needs ..." (no borrow where head and band fit, exactly head + band where they do not), "a covered row belongs to the band ..." (B1 on a band row over the body moves the level's cursor, on a head's row over it touches no body); Pick.zig "a picker's preview starts under its band ..." (in a reading pane: its text stays before the first row; line 60 at ⌈visible/3⌉ under the band, line 1 on the row right under it; Esc: its own text where it was); Prompt.zig "a search's current hit under C-r's band is put in the rows the band leaves the body ..."; the tests that read `band_rows` read Band.covered; body_layer's D10 test: `g`'s first-line target is under the rolled level's rows now (I2's named cost); GOLDENS re-recorded, every moved row: leader (spc, unmapped: the one line of cmds.txt stays on row 3 under the level's second row instead of row 5, the caret on it hidden), find (nomatch, topbar: a picker with nothing to preview leaves here.txt's line 1 on row 3 under the band instead of row 8; cancel: row 8 no longer listed as changed), ttyhelp (leaderworks: Help's band over the +Help pane's text, whose rows 10-20 keep the previous snap's text instead of moving down seven rows); a user saw the text jump on every SPC Down, Help, `:` with rows, registers Down and a rolled level wider than its tag; core-test 1115/1287 (172 skipped: +3), shell-test 1335/1338 (3 skipped: +3), pane-test 183/184, behaviour-test 280/280 and --replay 20 seeds 0 failures, process-test 0 of 147 failed (3 skipped; 3 goldens re-recorded), term-test 17/17, kitty-test 45/45; the dump fuzz at 40,000 join seeds and 40,000 + 1,779 image seeds 11/11; the soak `replicas -- --clients 5 --rtt 30,80,207`: diverged 0, unequal 0, quiet checks 580/0 480/0 675/0, unlisted stops 0, the corpus 22 of 22 scenes the same, no leak; load 1.2 to 10.9
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Band.zig')
| -rw-r--r-- | core/Band.zig | 251 |
1 files changed, 188 insertions, 63 deletions
diff --git a/core/Band.zig b/core/Band.zig index cd4ca75b..8ee5c9f0 100644 --- a/core/Band.zig +++ b/core/Band.zig @@ -1,13 +1,14 @@ //! The band (walk UI, pick-ui SPEC.md §3.6): rows hanging under a pane's -//! tag while it is out of rest, in the tag's tint, pushing its body down: -//! the tag unrolled. Its steps stand side by side, each a column of rows +//! tag while it is out of rest, in the tag's tint, drawn over the top rows +//! of its body, which stay where they were (UX DESIGN I1): the tag +//! unrolled. Its steps stand side by side, each a column of rows //! (a level, Help's rows, a doc; later a picker's acts and sources, a //! prompt's history, the registers), a one-cell rule between them, right //! of a spine under each of the head's key cells. //! //! Derived from the live view's state each time it is asked (`of`), never //! stored (the coordinator's R2): the layout reads its height (`takes`, -//! Pardes.sync, layout.floorRows), the frame paints it (draw.zig +//! `covered`, layout.floorRows), the frame paints it (draw.zig //! joinBand) as a tag layer of kind `.band`, and the mouse reads its words //! (`line`): read-only text, which B2 executes and B3 looks at as a tag's. //! @@ -131,20 +132,24 @@ pub fn takes(p: *Pardes, id: usize) u16 { return @max(doc_rows, levelRows(n)); } -/// A terminal's and a kind's band is drawn over the top rows of its body -/// (UX D6's borrowing, R3: drawn, never written): a transient state never -/// resizes a pty under a program or a kind's view (a PDF's), whose size -/// only the user's resize changes. Their `band_rows` stay 0. -pub fn over(pane: *const Pane) bool { - return pane.isTerminal() or pane.addon != null; -} - -/// The rows pane `id`'s band is drawn on: those it takes from the layout, -/// or over a terminal's or a kind's body, as many of its body rows as the -/// band wants. -pub fn shownRows(p: *Pardes, pane: *const Pane, id: usize) u16 { - if (pane.band_rows > 0 or !over(pane) or pane.collapsed) return pane.band_rows; - return @min(takes(p, id), p.view().rects[id].h -| pane.tag_rows); +/// Where pane `id`'s tag out of rest is drawn, in rows from its top (UX +/// DESIGN I1): its head's text (`text`, the rows its own text keeps from +/// rest at least where no band hangs under it) and the band under that +/// (`band`), as many as the pane has; `over` of them past the tag's own +/// rows (`tag_rows`, its rows at rest), drawn over the top rows of its +/// body, which never move for them. A picker's band keeps a body of +/// `body_rows` under it (UX D6), any other state only the pane's rows. +/// Asked of the state alone, as `takes` is: the layout, the frame and a +/// click ask it of the same step. +pub const Covered = struct { text: u16, band: u16, over: u16 }; +pub fn covered(p: *Pardes, pane: *const Pane, id: usize) Covered { + if (pane.collapsed or TagState.hostOf(p) != id) return .{ .text = pane.tag_rows, .band = 0, .over = 0 }; + const h = p.view().rects[id].h; + const text = @min(layout.headRows(p, id), h); + const keep: u16 = if (p.view().tag_state.kind == .pick) body_rows else 0; + const band = @min(takes(p, id), h -| text -| keep); + const shown = if (band > 0) text else @min(@max(text, pane.tag_rows), pardes.MAX_TAG_ROWS); + return .{ .text = shown, .band = band, .over = (shown + band) -| pane.tag_rows }; } fn levelRows(n: u16) u16 { @@ -696,8 +701,10 @@ test "a narrow band gives way and keeps its spines: the doc goes, the steps star const s = try p.render(a); const r = p.view().rects[id]; const tag_y = p.tagTop(pane, r); - try std.testing.expectEqual(@as(u16, 1), pane.tag_rows - pane.band_rows); - try std.testing.expectEqual(@max(rest, 1 + band.height), pane.tag_rows); + const at = covered(p, pane, id); + try std.testing.expectEqual(@as(u16, 1), at.text); + try std.testing.expectEqual(rest, pane.tag_rows); + try std.testing.expectEqual((1 + band.height) -| rest, at.over); try std.testing.expectEqual(tag_y + 1, bandLayer(p, id).?.viewport.y); for (band.spines[0..band.nspines]) |col| try std.testing.expectEqualStrings("│", s.at(r.x + pardes.TAG_TEXT_INSET + col, tag_y + 1).grapheme()); try std.testing.expect(std.mem.indexOf(u8, try layerRow(a, bandLayer(p, id).?, 0), "▶") != null); @@ -715,7 +722,7 @@ test "out of rest with no band, the rows a tag keeps from rest stay blank: a spi // A search prompt: a key cell in its head, no band under it. p.update(.{ .key = .{ .cp = '/', .text = "/" } }); p.sync(); - try std.testing.expectEqual(@as(u16, 0), pane.band_rows); + try std.testing.expectEqual(@as(u16, 0), covered(p, pane, id).band); try std.testing.expectEqual(rest, pane.tag_rows); var frame = std.heap.ArenaAllocator.init(std.testing.allocator); defer frame.deinit(); @@ -828,7 +835,7 @@ test "a row longer than its room is cut with `…`: a path from the left, anythi try std.testing.expectEqualStrings("short", fits.text); } -test "SPC Down unrolls the level into a band under the tag's text, the body pushed down and never drawn over; Up on its first row rolls it up" { +test "SPC Down unrolls the level into a band under the tag's text, drawn over the top rows of the body, which stays where it was (UX DESIGN I1); Up on its first row rolls it up" { const Key = pardes.Key; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 }); defer p.deinit(); @@ -840,30 +847,40 @@ test "SPC Down unrolls the level into a band under the tag's text, the body push const r = p.view().rects[id]; const text_rows = pane.tag_rows; const body_top = p.bodyTop(pane, r); + const rows = pane.rows; _ = try p.render(frame.allocator()); try std.testing.expect(bandLayer(p, id) == null); p.update(.{ .key = .{ .cp = ' ' } }); p.update(.{ .key = .{ .cp = Key.down } }); try std.testing.expect(p.view().tag_state.unrolled); // SPC's top has more than nine children: two columns, and a doc. - try std.testing.expect(pane.band_rows >= doc_rows); - try std.testing.expectEqual(text_rows + pane.band_rows, pane.tag_rows); - try std.testing.expectEqual(body_top + pane.band_rows, p.bodyTop(pane, r)); + const at = covered(p, pane, id); + try std.testing.expect(at.band >= doc_rows); + try std.testing.expect(at.over > 0); + // The tag keeps its rows at rest, the body its first row and its size. + try std.testing.expectEqual(text_rows, pane.tag_rows); + try std.testing.expectEqual(body_top, p.bodyTop(pane, r)); + try std.testing.expectEqual(rows, pane.rows); + try std.testing.expectEqual(at.over, pane.view.covered); _ = frame.reset(.retain_capacity); const s = try p.render(frame.allocator()); const layer = bandLayer(p, id).?; - try std.testing.expectEqual(p.tagTop(pane, r) + text_rows, layer.viewport.y); - try std.testing.expectEqual(pane.band_rows, layer.viewport.h); - // The body region starts under the band: nothing is drawn over it. + try std.testing.expectEqual(p.tagTop(pane, r) + at.text, layer.viewport.y); + try std.testing.expectEqual(at.band, layer.viewport.h); + // The body region starts where it did at rest: the band is over it. const body = s.region(.body, id).?; - try std.testing.expectEqual(layer.viewport.y + layer.viewport.h, body.rect.y); + try std.testing.expectEqual(body_top, body.rect.y); + try std.testing.expect(layer.viewport.y + layer.viewport.h > body.rect.y); const first = try layerRow(frame.allocator(), layer, 0); try std.testing.expect(std.mem.indexOf(u8, first, "│") != null); try std.testing.expect(std.mem.indexOf(u8, first, "▶ b buffer…") != null); - // The grid has the same row, where the layer is. + // The grid has the same rows, where the layer is, the body's under + // them drawn first: its last covered row is the band's. var grid: std.ArrayList(u8) = .empty; for (s.cells[@as(usize, layer.viewport.y) * s.cols ..][layer.viewport.x..][0..layer.viewport.w]) |cell| try grid.appendSlice(frame.allocator(), cell.grapheme()); try std.testing.expect(std.mem.indexOf(u8, grid.items, "▶ b buffer…") != null); + const spine = (try of(p, frame.allocator(), pane, id)).?.spines[0]; + try std.testing.expectEqualStrings("│", s.at(r.x + pardes.TAG_TEXT_INSET + spine, layer.viewport.y + layer.viewport.h - 1).grapheme()); // The head names the level and says how to roll it up. const head = try tagline.tagText(p, frame.allocator(), pane); try std.testing.expect(std.mem.startsWith(u8, head, "␣ SPC ") and std.mem.endsWith(u8, head, " ↑ roll up · ? field · esc")); @@ -874,7 +891,7 @@ test "SPC Down unrolls the level into a band under the tag's text, the body push try std.testing.expect(p.view().tag_state.unrolled); p.update(.{ .key = .{ .cp = Key.up } }); try std.testing.expect(!p.view().tag_state.unrolled); - try std.testing.expectEqual(@as(u16, 0), pane.band_rows); + try std.testing.expectEqual(@as(u16, 0), covered(p, pane, id).band); try std.testing.expectEqual(body_top, p.bodyTop(pane, r)); // Unrolled, Right enters the cursor's group and Left leaves it. p.update(.{ .key = .{ .cp = Key.down } }); @@ -884,13 +901,14 @@ test "SPC Down unrolls the level into a band under the tag's text, the body push p.update(.{ .key = .{ .cp = Key.left } }); try std.testing.expectEqual(@as(u8, 0), p.view().leader_n); p.update(.{ .key = .{ .cp = Key.escape } }); - try std.testing.expectEqual(@as(u16, 0), pane.band_rows); + try std.testing.expectEqual(@as(u16, 0), covered(p, pane, id).band); + try std.testing.expectEqual(@as(u16, 0), pane.view.covered); try std.testing.expect(!p.view().tag_state.unrolled); } -test "a band keeps its pane's body 60 % of the pane, borrowed from its column; where the column has not the rows, the band gives way before the body drops under 6" { +test "a level's band covers what it needs: its pane keeps its rows where its head and band fit, and borrows from its column only the rows they need where they do not (UX DESIGN I1)" { const Key = pardes.Key; - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 }); + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 60 }); defer p.deinit(); _ = try p.setTestFile("one\n"); const top = p.view().active; @@ -899,42 +917,25 @@ test "a band keeps its pane's body 60 % of the pane, borrowed from its column; w p.newScratchBelow(low); p.view().active = low; p.sync(); + const before = p.view().rects; p.update(.{ .key = .{ .cp = ' ' } }); p.update(.{ .key = .{ .cp = Key.down } }); const pane = p.panes[low].?; - const r = p.view().rects[low]; - try std.testing.expect(pane.band_rows >= doc_rows); - try std.testing.expect(@as(u32, r.h -| pane.tag_rows) * 5 >= @as(u32, r.h) * 3); + const at = covered(p, pane, low); + const need = at.text + at.band; + try std.testing.expect(at.band == takes(p, low) and need <= before[low].h); + try std.testing.expectEqualDeep(before, p.view().rects); p.update(.{ .key = .{ .cp = Key.escape } }); - // A window of 12 rows: the band shrinks, the body keeps 6. - p.update(.{ .resize = .{ .cols = 120, .rows = 12 } }); + // A window of 24 rows: seven a pane, the head and band need more. + p.update(.{ .resize = .{ .cols = 120, .rows = 24 } }); + const short = p.view().rects[low].h; + try std.testing.expect(short < need); p.update(.{ .key = .{ .cp = ' ' } }); p.update(.{ .key = .{ .cp = Key.down } }); - p.sync(); - const short = p.view().rects[low]; - try std.testing.expect(short.h -| pane.tag_rows >= 6 or pane.band_rows == 0); - try std.testing.expect(pane.band_rows < Band.takes(p, low)); -} - -test "a pane whose body would drop below six rows under its band borrows them from its column" { - const Key = pardes.Key; - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 24 }); - defer p.deinit(); - _ = try p.setTestFile("one\n"); - const top = p.view().active; - p.newScratchBelow(top); - const low = p.view().active; - p.newScratchBelow(low); - p.view().active = low; - p.sync(); - const before = p.view().rects[low].h; - p.update(.{ .key = .{ .cp = ' ' } }); - p.update(.{ .key = .{ .cp = Key.down } }); - const pane = p.panes[low].?; const r = p.view().rects[low]; - try std.testing.expect(r.h > before); - // Its body six rows at least (UX D6): a column too short for 60 %. - try std.testing.expect(r.h -| pane.tag_rows >= 6); + const grown = covered(p, pane, low); + try std.testing.expectEqual(need, r.h); + try std.testing.expectEqual(at, grown); // No pane dims out of rest (UX D9): the others look as at rest. var frame = std.heap.ArenaAllocator.init(std.testing.allocator); defer frame.deinit(); @@ -944,7 +945,7 @@ test "a pane whose body would drop below six rows under its band borrows them fr try std.testing.expect(!s.at(other.x + 3, other.y + 1).style.dim); try std.testing.expect(!s.at(r.x + 3, r.y).style.dim); p.update(.{ .key = .{ .cp = Key.escape } }); - try std.testing.expectEqual(before, p.view().rects[low].h); + try std.testing.expectEqual(short, p.view().rects[low].h); } test "the band's words are read-only text: B2 runs one, the tag back at rest" { @@ -1114,3 +1115,127 @@ test "an empty level gives no rows: SPC unrolled on an addon's group, or describ _ = try p.render(a); } } + +test "out of rest the body stays where it was: under a rolled level, SPC Down, Help, `:`, the registers and a picker that has not previewed, every row of its text on the screen row it had at rest, its first row and its size the same; Esc leaves the body's rows as at rest (UX DESIGN I1)" { + const Key = pardes.Key; + const gpa = std.testing.allocator; + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 40 }); + defer p.deinit(); + p.settings.jumps = .walk; + var text: std.ArrayList(u8) = .empty; + defer text.deinit(gpa); + for (1..121) |i| try text.print(gpa, "line {d} of the text\n", .{i}); + const pane = try p.setTestFile(text.items); + const id = p.view().active; + pane.focus = .body; + p.clock.now_ns = 5 * std.time.ns_per_s; + p.clock.stepped_ns = p.clock.now_ns; + // Into the text: the view scrolled, the caret on a row under the top. + for ("60jk") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); + p.sync(); + var frame = std.heap.ArenaAllocator.init(gpa); + defer frame.deinit(); + const r = p.view().rects[id]; + const body_top = p.bodyTop(pane, r); + const tag_rows, const rows, const top = .{ pane.tag_rows, pane.rows, pane.file.?.scroll }; + try std.testing.expect(top > 0); + const rest = try gpa.dupe(pardes.Cell, (try p.render(frame.allocator())).cells); + defer gpa.free(rest); + const cols = p.surface.cols; + const list = try std.fmt.allocPrint(gpa, "{s}:3:1 line 3 of the text\n", .{pane.file.?.path}); + defer gpa.free(list); + for ([_][]const u8{ "rolled", "unrolled", "help", "colon", "registers", "picker" }) |state| { + if (std.mem.eql(u8, state, "picker")) { + pardes.Pick.open(p, id, .list, "Refs", "", list); + } else { + const keys: []const Key = if (std.mem.eql(u8, state, "rolled")) &.{.{ .cp = ' ' }} else if (std.mem.eql(u8, state, "unrolled")) &.{ .{ .cp = ' ' }, .{ .cp = Key.down } } else if (std.mem.eql(u8, state, "help")) &.{ .{ .cp = ' ' }, .{ .cp = '?' } } else if (std.mem.eql(u8, state, "colon")) &.{.{ .cp = ':' }} else &.{ .{ .cp = '"' }, .{ .cp = Key.down } }; + for (keys) |k| p.update(.{ .key = k }); + // A rolled level shows after its delay. + p.advance(p.clock.now_ns); + if (p.view().tag_state.due_ns > p.clock.now_ns) p.clock.now_ns = p.view().tag_state.due_ns; + } + p.sync(); + errdefer std.debug.print("state {s}\n", .{state}); + try std.testing.expect(TagState.hostOf(p) == id); + const at = covered(p, pane, id); + try std.testing.expect(at.over > 0); + try std.testing.expectEqual(tag_rows, pane.tag_rows); + try std.testing.expectEqual(rows, pane.rows); + try std.testing.expectEqual(top, pane.file.?.scroll); + try std.testing.expectEqual(body_top, p.bodyTop(pane, r)); + _ = frame.reset(.retain_capacity); + const s = try p.render(frame.allocator()); + // Under the rows drawn over it, the body's text on its rows. + var y = body_top + at.over; + while (y < r.y + r.h) : (y += 1) for (r.x + pardes.config.GUTTER..r.x + r.w) |x| { + const i = @as(usize, y) * cols + x; + try std.testing.expectEqualStrings(rest[i].grapheme(), s.cells[i].grapheme()); + }; + p.update(.{ .key = .{ .cp = Key.escape } }); + p.sync(); + try std.testing.expect(TagState.hostOf(p) == null); + _ = frame.reset(.retain_capacity); + const back = try p.render(frame.allocator()); + y = body_top; + while (y < r.y + r.h) : (y += 1) for (r.x..r.x + r.w) |x| { + const i = @as(usize, y) * cols + x; + try std.testing.expect(std.meta.eql(rest[i], back.cells[i])); + }; + } +} + +test "a covered row belongs to the band: a click on a band row over the body moves the band's cursor, on the head's row over it runs or looks at its word, never the body under them (UX DESIGN I1)" { + const Key = pardes.Key; + const gpa = std.testing.allocator; + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 120, .rows = 40 }); + defer p.deinit(); + var text: std.ArrayList(u8) = .empty; + defer text.deinit(gpa); + for (1..61) |i| try text.print(gpa, "line {d} of the text\n", .{i}); + const pane = try p.setTestFile(text.items); + const id = p.view().active; + pane.focus = .body; + p.sync(); + const r = p.view().rects[id]; + const body_top = p.bodyTop(pane, r); + p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = Key.down } }); + const at = covered(p, pane, id); + var frame = std.heap.ArenaAllocator.init(gpa); + defer frame.deinit(); + const band = (try of(p, frame.allocator(), pane, id)).?; + // The band's last row, over the body: its first step's row there. + const row: u16 = at.band - 1; + const y = p.tagTop(pane, r) + at.text + row; + try std.testing.expect(y >= body_top); + const ln = try band.line(frame.allocator(), p.settings.tab, row); + const part = ln.parts[0]; + const x = r.x + pardes.TAG_TEXT_INSET + part.col + 1; + const caret = .{ pane.body.cur_row, pane.body.cur_col }; + p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = x, .row = y } }); + p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = x, .row = y } }); + var children: [bindings.max_children]bindings.Child = undefined; + try std.testing.expectEqual(bindings.level(p, .leader, "", &children)[part.row.index].key, p.view().tag_state.hi); + try std.testing.expect(p.view().tag_state.unrolled); + try std.testing.expectEqual(caret, .{ pane.body.cur_row, pane.body.cur_col }); + try std.testing.expectEqual(pardes.Pane.Focus.body, pane.focus); + p.update(.{ .key = .{ .cp = Key.escape } }); + // SPC's rolled level, rows over the body under its first: a click on + // one is the head's, not the body's (B1 there does nothing). + p.clock.now_ns = 5 * std.time.ns_per_s; + p.clock.stepped_ns = p.clock.now_ns; + p.update(.{ .key = .{ .cp = ' ' } }); + p.advance(p.clock.now_ns); + p.clock.now_ns = p.view().tag_state.due_ns; + p.sync(); + const rolled = covered(p, pane, id); + try std.testing.expect(rolled.band == 0 and rolled.text > pane.tag_rows); + const hy = p.tagTop(pane, r) + rolled.text - 1; + try std.testing.expect(hy >= body_top); + const hx = r.x + pardes.TAG_TEXT_INSET + 6; + p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = hx, .row = hy } }); + p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = hx, .row = hy } }); + try std.testing.expect(TagState.hostOf(p) == id); + try std.testing.expectEqual(caret, .{ pane.body.cur_row, pane.body.cur_col }); + try std.testing.expectEqual(pardes.Pane.Focus.body, pane.focus); +} |
