diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 12:00:13 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 12:09:48 -0300 |
| commit | 8af71053adc306b81c39429d6d1758bb6c81d363 (patch) | |
| tree | 4f4dd30cfba4db91da523104025fe544d2fc1a6b /core/body_layer.zig | |
| parent | 40f4750dc3fe870349c13649d22b4687896bbf7b (diff) | |
| parent | ae138cd257f862f226f3f9561b98b7c0518bfcf5 (diff) | |
| download | pardes-8af71053adc306b81c39429d6d1758bb6c81d363.tar.gz pardes-8af71053adc306b81c39429d6d1758bb6c81d363.zip | |
walk UI M7: the fix round's X1 (lrzulkwu 40f4750dc3fe: band rows in the dumps and the digest (the soak's `views[0].rects` class), a picker's band capped at 40 % of its host pane at open E5.1, the band under the head E5.2, the notice row cut with `…` E5.4, a blank each side of a step's rule E5.5, Help's chord and word with its group as right-aligned meta E5.6, a doc with no room on the notice row E5.10, full-height `│` in the window E5.9, the tag rule under a band over a terminal E5.11) merged with X2 (suvlqwul ae138cd257f8: the soak typist's q guard, a message's detail only on request E5.3/D13, the err role's fallback E5.7, ` · N lines` kept dim after a search's count (E7's reversal of E5.8), a list of places in one column with its places dim E7 2b, the landing line at 1.5:1 and its span at 1.9:1 E7 7b, code actions Enter cannot apply dim with meta `command`/`other files` E5.12), both on G4's lurxouvq, resolved by meaning: the only text conflict was test/snapshots/fsearch.golden; Messages.noticeRow (X1's left-text cut and doc line, its `*Pardes` signature) and X2's D13 (detailUnder, detailAt, act, rollUp) touch different functions and merged clean, as did Core.zig (X1's sync, X2's updateInner arms) and Pick.zig (X1's `cap` and bandRows, X2's rowAt actions arm and steps' place column); BY MEANING: X1's E3 rule gives the band's last list step the remaining width, so X2's place column (padded to the widest place shown, Pick.steps) is no longer cut at 52 cells and still lines up (a row with a place is cut from the right by Band.cutRow, its `pre` set, so the column never shifts), and the actions picker's one step is the band's width, so its meta `command`/`other files` stands at the band's right end (X2's reading 8 asked for exactly that); TESTS (the merge's checks): Pick "a list of places ..." also asks the band's drawn rows (Band.of, band.line): the last step ends at the band's edge and the two rows' code in one column; Pick "code actions: a row that cannot be applied ..." also asks the band's first row to end ` command` at the band's width; GOLDEN: fsearch regenerated and every changed row read: against X1 only X2's rows (`g.txt:2:1: MARK a` and `6:1: MARK b` padded to `10:1: MARK c`'s column in list and ctrln, row 16's ` · N lines` cells in the dim ink); against X2 only X1's (the band from the row under the head, the reader borrowing a row so its body shows line 9 / 11, the stray `│` under the `/` prompt gone); no other golden moved; core-test 1095/1266 (171 skipped; X1 1090/1261 + X2 1088/1259 over the base's 1083/1254), the two extended tests filtered 11/11 each; process-test 1 of 147 failed before the update (fsearch, the conflicted golden) and fsearch 0 of 1 after it
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/body_layer.zig')
| -rw-r--r-- | core/body_layer.zig | 113 |
1 files changed, 105 insertions, 8 deletions
diff --git a/core/body_layer.zig b/core/body_layer.zig index 0107b3e0..f00da4a9 100644 --- a/core/body_layer.zig +++ b/core/body_layer.zig @@ -641,6 +641,28 @@ fn messageGhosts(p: *Pardes, s: *Surface, pane: *Pane, tx: u16, tw: u16, body_y: /// frame drawn last (its body layer when it has one, else the grid): a /// message's detail is text no buffer holds, read as it is shown. pub fn wordAt(p: *Pardes, arena: std.mem.Allocator, id: usize, row: usize, col: usize) !?[]const u8 { + const text = try drawnRow(p, arena, id, row) orelse return null; + const b = pardes.tagline.wordBoundsAtCol(text, panes.File.rawAtDisplay(p.settings.tab, text, col)) orelse return null; + if (b.lo == b.hi) return null; + return text[b.lo..b.hi]; +} + +/// The message whose words are drawn after its line at body row `row`, +/// text column `col` of pane `id` in the frame drawn last, when it has a +/// detail: a Look there unrolls it (UX D13). The words start at their +/// glyph, two blanks after the line (messageGhosts). +pub fn messageAt(p: *Pardes, arena: std.mem.Allocator, id: usize, row: u16, col: usize) !?*pardes.Messages.Said { + const pane = p.panes[id] orelse return null; + const said = pardes.Messages.detailAt(p, pane, pane.wrapAt(p.settings.tab, pane.textRow(row)).line) orelse return null; + const text = try drawnRow(p, arena, id, row) orelse return null; + var mark: [8]u8 = undefined; + const at = std.mem.lastIndexOf(u8, text, std.fmt.bufPrint(&mark, " {s} ", .{said.kind.glyph()}) catch return null) orelse return null; + return if (panes.File.rawAtDisplay(p.settings.tab, text, col) >= at + 2) said else null; +} + +/// Body row `row` of pane `id` as the frame drawn last shows it: its body +/// layer's when it has one, else the grid's. +fn drawnRow(p: *Pardes, arena: std.mem.Allocator, id: usize, row: usize) !?[]const u8 { const layer = &p.surface.body_layers[id]; const body = (p.surface.region(.body, id) orelse return null).rect; var text: std.ArrayList(u8) = .empty; @@ -651,9 +673,7 @@ pub fn wordAt(p: *Pardes, arena: std.mem.Allocator, id: usize, row: usize, col: if (row >= body.h) return null; for (0..body.w) |x| try text.appendSlice(arena, p.surface.at(body.x + @as(u16, @intCast(x)), body.y + @as(u16, @intCast(row))).grapheme()); } - const b = pardes.tagline.wordBoundsAtCol(text.items, panes.File.rawAtDisplay(p.settings.tab, text.items, col)) orelse return null; - if (b.lo == b.hi) return null; - return text.items[b.lo..b.hi]; + return text.items; } /// A picker's landing line (UX D7): its text on the hit ground across @@ -1141,7 +1161,7 @@ fn rowText(s: *const Surface, x: u16, y: u16, buf: []u8) []const u8 { return buf[0..n]; } -test "a build error is said where its cause is: the mark on its file's tag, its words after its line, its detail under the caret's line pushing the rows below down, the walk on the notice row" { +test "a build error is said where its cause is: the mark on its file's tag, its words after its line, its detail, asked for, under its line pushing the rows below down, the walk on the notice row" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 20 }); defer p.deinit(); const pane = try p.setTestFile("one\ntwo\nthree\nfour\nfive\nsix\n"); @@ -1172,8 +1192,10 @@ test "a build error is said where its cause is: the mark on its file's tag, its // elsewhere. try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 2, &buf), "three \u{2717} expected 2 argument(s), found 3") != null); try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "four") != null); - // The caret on line 3: its detail under it, the rows below two rows down. + // The caret on line 3 and its detail asked for (K, UX D13): under the + // line, the rows below two rows down. pane.body.cur_row = 2; + err.open = true; _ = frame.reset(.retain_capacity); s = try p.render(frame.allocator()); try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "const x = f(1, 2, 3);") != null); @@ -1202,6 +1224,7 @@ test "a click under a message's detail lands on the row drawn there, a click on err.detail_len = 2; pane.focus = .body; pane.body.cur_row = 2; + err.open = true; p.sync(); var frame = std.heap.ArenaAllocator.init(std.testing.allocator); defer frame.deinit(); @@ -1215,9 +1238,14 @@ test "a click under a message's detail lands on the row drawn there, a click on p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = x, .row = body.y + 6 } }); p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = x, .row = body.y + 6 } }); try std.testing.expectEqual(@as(i32, 4), pane.body.cur_row); - // On line 3 again, its detail drawn: a click on the detail is on the - // line it explains, and the detail stays. - pane.body.cur_row = 2; + // On line 3 again, its detail asked for again (the click, a motion, + // rolled it up): a click on the detail is on the line it explains, and + // the detail stays. + try std.testing.expect(!err.open); + p.update(.{ .key = .{ .cp = 'k' } }); + p.update(.{ .key = .{ .cp = 'k' } }); + p.update(.{ .key = .{ .cp = 'K' } }); + try std.testing.expect(err.open); _ = frame.reset(.retain_capacity); s = try p.render(frame.allocator()); const wrap_at = std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "Wrap").?; @@ -1317,3 +1345,72 @@ test "a motion root's level paints its targets in place of their lines' numbers, s = try p.render(a); try std.testing.expectEqualStrings("5", Field.of(s, gutter, body.y + 4, number, &buf)); } + +test "a message's detail unrolls only on request (UX D13): the caret passing its line inserts no rows; K there unrolls it under the line and the caret leaving the line rolls it up; SPC e there unrolls it; a Look on its words after the line unrolls it; K with two selections is keep's" { + const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 20 }); + defer p.deinit(); + const pane = try p.setTestFile("one\ntwo\nthree\nfour\nfive\nsix\n"); + const id = p.view().active; + const err = pardes.Messages.keep(p, .@"error", 0, "@p9 zig build", "exit 1"); + err.places[0] = .{ .line = 3, .col = 1 }; + err.places[0].path.set("/test.txt"); + err.places[0].text.set("expected 2 argument(s), found 3"); + err.places_len = 1; + err.detail[0] = .{}; + err.detail[0].set("const x = f(1, 2, 3);"); + err.detail_len = 1; + pane.focus = .body; + p.sync(); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + var buf: [512]u8 = undefined; + // The caret onto line 3 and past it: no row inserted or removed. + p.update(.{ .key = .{ .cp = 'j' } }); + p.update(.{ .key = .{ .cp = 'j' } }); + try std.testing.expectEqual(@as(i32, 2), pane.body.cur_row); + var s = try p.render(frame.allocator()); + const body = s.region(.body, id).?.rect; + try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 2, &buf), "three \u{2717} expected") != null); + try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "four") != null); + // K there: its detail under the line, the rows below one lower; no + // keep prompt. + p.update(.{ .key = .{ .cp = 'K' } }); + try std.testing.expectEqual(pardes.TagState.Kind.rest, p.view().tag_state.kind); + _ = frame.reset(.retain_capacity); + s = try p.render(frame.allocator()); + try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "const x = f(1, 2, 3);") != null); + try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 4, &buf), "four") != null); + // The next motion rolls it up; back on the line, nothing comes back. + p.update(.{ .key = .{ .cp = 'j' } }); + p.update(.{ .key = .{ .cp = 'k' } }); + try std.testing.expect(!err.open); + _ = frame.reset(.retain_capacity); + s = try p.render(frame.allocator()); + try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "four") != null); + // SPC e there: unrolled, the error still live; K rolls it up. + p.update(.{ .key = .{ .cp = ' ' } }); + p.update(.{ .key = .{ .cp = 'e' } }); + try std.testing.expect(err.open); + try std.testing.expectEqual(@as(usize, 1), p.messages.live_len); + _ = frame.reset(.retain_capacity); + s = try p.render(frame.allocator()); + try std.testing.expect(std.mem.indexOf(u8, rowText(s, body.x, body.y + 3, &buf), "const x = f(1, 2, 3);") != null); + p.update(.{ .key = .{ .cp = 'K' } }); + try std.testing.expect(!err.open); + // A Look (B3) on its words after the line: unrolled, the caret where + // it was. + _ = frame.reset(.retain_capacity); + s = try p.render(frame.allocator()); + const words = std.mem.indexOf(u8, rowText(s, body.x, body.y + 2, &buf), "expected").?; + const wx = body.x + @as(u16, @intCast(words)) + 1; + p.update(.{ .mouse = .{ .button = .right, .kind = .press, .col = wx, .row = body.y + 2 } }); + p.update(.{ .mouse = .{ .button = .right, .kind = .release, .col = wx, .row = body.y + 2 } }); + while (p.nextEffect()) |_| {} + try std.testing.expect(err.open); + try std.testing.expectEqual(@as(i32, 2), pane.body.cur_row); + // K with two selections is keep's prompt, the detail as it was. + p.update(.{ .key = .{ .cp = 'C' } }); + try std.testing.expect(pane.body.nsel > 0); + p.update(.{ .key = .{ .cp = 'K' } }); + try std.testing.expectEqual(pardes.TagState.Kind.prompt, p.view().tag_state.kind); +} |
