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/Messages.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/Messages.zig')
| -rw-r--r-- | core/Messages.zig | 98 |
1 files changed, 81 insertions, 17 deletions
diff --git a/core/Messages.zig b/core/Messages.zig index b89b9676..72d5193d 100644 --- a/core/Messages.zig +++ b/core/Messages.zig @@ -129,15 +129,17 @@ pub const Said = struct { text: Buf(256) = .{}, places: [max_places]Place = undefined, places_len: u8 = 0, - /// The lines that explain it, shown under its first place's line while - /// the caret is on it. + /// The lines that explain it, shown under the line it names when asked + /// (`open`). detail: [max_detail]Buf(128) = undefined, detail_len: u8 = 0, /// The serial of the pane it is about, 0 for none in particular. pane: u32 = 0, asks: Ask = .none, - /// Its detail shown under its first place's line whatever the caret - /// (a question's Diff). + /// Its detail unrolled, on request only (UX D13): K, SPC e or a Look on + /// its words on the caret's line (detailAt), shown under that line until + /// the caret leaves it (rollUp); a question's Diff under its place + /// whatever the caret, until `d` again. open: bool = false, /// How many times in a row it was said. n: u16 = 1, @@ -520,8 +522,9 @@ pub fn answer(p: *Pardes, i: usize, key: u8) bool { return true; } -/// SPC e (the Message word, SPEC §10.4), on the message the notice row -/// leads with: an error that names places lands them as a list in pane +/// SPC e (the Message word, SPEC §10.4): on a line a message names, its +/// detail not unrolled, that detail (UX D13); else on the message the +/// notice row leads with: an error that names places lands them as a list in pane /// `id`'s walk (Pick's `list`, its word `✗ <cause>` in the trail), the /// first landed on, n and N walking the rest, and the error goes (a /// +Search under the pane where jumps do not walk, or for a 9P script: @@ -529,6 +532,13 @@ pub fn answer(p: *Pardes, i: usize, key: u8) bool { /// else, or nothing, opens the history. pub fn act(p: *Pardes, id: usize) void { const m = &p.messages; + // On a line a message names, its detail not unrolled: unrolled (UX + // D13), the message kept; asked again, the walk below. + if (id < MAX_PANES) if (p.panes[id]) |pane| if (pane.focus == .body) if (detailAt(p, pane, pane.body.cur_row)) |s| if (!s.open) { + s.open = true; + p.needs_frame = true; + return; + }; const lead = m.headline() orelse return history(p, id); if (lead.kind == .question) { p.view().answering = lead.pane; @@ -975,29 +985,83 @@ pub fn collectNotices(p: *Pardes, pane: *Pane, r: Rect) void { } } -/// A message's detail under the caret's line (SPEC §10.2), as a body of -/// `body_h` rows shows it: the row of that line's last row, how many of the -/// detail's lines fit under it, the message (the first naming the line, as -/// the words after it are); only in the pane with the keyboard, in its body. -/// Bounded by the live messages' places and the rows shown. +/// A message's detail unrolled (SPEC §10.2, UX D13: on request only), as a +/// body of `body_h` rows shows it: the row of its line's last row, how many +/// of the detail's lines fit under it, the message. The line is the +/// caret's, where it was asked (the caret leaving it rolls it up), or a +/// question's place; its message the first naming it, as the words after +/// it are (firstAt). The caret passing a line never unrolls one. Only in +/// the pane with the keyboard, in its body. Bounded by the live messages' +/// places and the rows shown. pub fn detailUnder(p: *const Pardes, pane: *Pane, active: bool, body_h: u16) ?struct { row: u16, rows: u16, said: *const Said } { if (!active or pane.focus != .body or p.messages.live_len == 0) return null; const f = pane.file orelse return null; - const caret = @max(0, pane.body.cur_row); - const said = found: for (p.messages.live[0..p.messages.live_len]) |*s| { - for (s.places[0..s.places_len]) |*place| if (place.line == caret + 1 and std.mem.eql(u8, place.path.slice(), f.path)) break :found s; - } else return null; + const m = &p.messages; + const caret: u32 = @intCast(@max(0, pane.body.cur_row)); + const said, const line = found: { + if (m.firstAt(f.path, caret + 1)) |i| if (m.live[i].open) break :found .{ &m.live[i], @as(i32, @intCast(caret)) }; + for (m.live[0..m.live_len], 0..) |*s, i| if (s.open and s.kind == .question and s.places_len > 0 and std.mem.eql(u8, s.places[0].path.slice(), f.path)) + if (m.firstAt(f.path, s.places[0].line) == i) break :found .{ s, @as(i32, @intCast(s.places[0].line -| 1)) }; + return null; + }; if (said.detail_len == 0) return null; var row: u16 = 0; while (row < body_h) : (row += 1) { - if (pane.wrapAt(p.settings.tab, row).line != caret) continue; - if (row + 1 < body_h and pane.wrapAt(p.settings.tab, row + 1).line == caret) continue; + if (pane.wrapAt(p.settings.tab, row).line != line) continue; + if (row + 1 < body_h and pane.wrapAt(p.settings.tab, row + 1).line == line) continue; const k: u16 = @intCast(@min(said.detail_len, body_h - row - 1)); return if (k == 0) null else .{ .row = row, .rows = k, .said = said }; } return null; } +/// The first live message naming line `line` (1-based) of `path`: the one +/// whose words are drawn after that line (body_layer messageGhosts). +fn firstAt(m: *const Messages, path: []const u8, line: u32) ?usize { + for (m.live[0..m.live_len], 0..) |*s, i| for (s.places[0..s.places_len]) |*place| { + if (line > 0 and place.line == line and std.mem.eql(u8, place.path.slice(), path)) return i; + }; + return null; +} + +/// The message whose words line `row` (0-based) of `pane`'s file shows, +/// when it has a detail to unroll (UX D13): what K with one selection, SPC +/// e and a Look on those words ask for. Not a question's (its Diff is `d`). +pub fn detailAt(p: *Pardes, pane: *const Pane, row: i32) ?*Said { + const f = pane.file orelse return null; + if (row < 0) return null; + const s = &p.messages.live[p.messages.firstAt(f.path, @intCast(row + 1)) orelse return null]; + if (s.detail_len == 0 or s.kind == .question) return null; + return s; +} + +/// The keyboard's pane and its caret's line while a detail is unrolled on +/// request; null with none (nothing to roll up: nothing else read). +pub const Caret = struct { active: usize, row: i32 }; + +pub fn unrolledAt(p: *const Pardes) ?Caret { + const v = p.view(); + for (p.messages.live[0..p.messages.live_len]) |*s| if (s.open and s.kind != .question) { + const pane = p.panes[v.active] orelse return .{ .active = v.active, .row = -1 }; + return .{ .active = v.active, .row = pane.body.cur_row }; + }; + return null; +} + +/// After a key or a click (Core.update): the caret left its line, or the +/// keyboard went to another pane, since `was`: every detail unrolled on +/// request rolls up (UX D13: the next motion; a motion along the line, or +/// a click on the detail, which puts the caret on the line it explains, +/// keeps it), a question's Diff stays. +pub fn rollUp(p: *Pardes, was: ?Caret) void { + const before = was orelse return; + const now = unrolledAt(p) orelse return; + if (std.meta.eql(before, now)) return; + for (p.messages.live[0..p.messages.live_len]) |*s| if (s.kind != .question) { + s.open = false; + }; +} + /// The bands a pane shows over `r` below its `tag_rows`: the live view's /// each step, and any view's for its kind's facts (Kind.viewOf), made from /// what a dump keeps (the bands are derived). |
