diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 12:44:35 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 13:02:49 -0300 |
| commit | 51f211d694beff9a389ab519f2286cef077adb81 (patch) | |
| tree | 2df93ee551f2820011f6f67b32f5131fbd927888 /core/Trail.zig | |
| parent | 3d60aa05ec1a6f9ed535186be6c6c2850c71b24d (diff) | |
| parent | d7b01dfc187244b6613a954d82552675d3bd2689 (diff) | |
| download | pardes-51f211d694beff9a389ab519f2286cef077adb81.tar.gz pardes-51f211d694beff9a389ab519f2286cef077adb81.zip | |
merge (M3): tonplrtr 3d60aa05ec1a (L2a: the tags, grips, band and notice row drawn from the chrome, the old ChromeTheme, Roles and Grounds views deleted, part H's inks, the path dim while a pane previews another file; M2's wxvzvomn, dump.load resolves the chrome; FP's PDF preview leak, the exec rerun's spawn stop, ABI 3.4's PDF hits) with rppqvrqx d7b01dfc1872 (W9, walkui UX DESIGN part O on W5's part M: the tag stays at rest and the head hangs under it as the band's first row, a picker hangs under the tag of the pane with the keyboard, the mouse never ends it, TagState.waits, Pick.tall, the act/source row gone), resolved: THE CODE: core/draw.zig joinBand draws W5/W9's layout with L2a's inks: the head (TagState.head) and the band from `p.chrome().on(focus or plain)` (its keys `inks.key`, its error `inks.severity[0]`, its dim and rule the ground's), the band's rows' keys, chords, `pre` (the name tint `chrome.name[g]`), dim, kind and matched letters as L2a drew them, W9's loop variable `i` kept; paintPaneTag keeps W9's question in the tag (TagState.asking) and L2a's single tag ink (W9's out-of-rest `text_style` gone with L2a's: a question's text and the tag's own were the same ink once Roles went), and draws the computed words in the words' ink whenever the tag does not ask (L2a's `head == null and !asks`: out of rest the tag is the rest tag now, so its words are the rest words); render's head-and-band gutter (W9's `at.tag`) on L2a's ground; draw's key-ink test reads `p.chrome().on(.focus)` and W9's `? help`; core/TagState.zig's W5 test "out of rest a tag is drawn as at rest ..." (renamed: "... but the box and its path's ink, the path its own and dim ...") lets the path's cells differ in their ink alone, the dim ink, the dimmed text ending `/far.txt`: L2a's zrxurkop dims a tag's path while its body previews another file (the coordinator's ruling, UX DESIGN M7.2), which the test, written before it on W5's tree, read as a moved cell (core-test failed it at TagState.zig:1741 on the merge as jj made it); THE GOLDENS: process-test -- --update re-recorded all 103 golden cases, the 102 golden files (every one with a frame out of rest among them), and moved exactly the two in conflict, fsearch and selregex, each now W9's text rows byte for byte (gdiff.py: no snap row differs from W9's) and L2a's inks on them; read cell by cell (.scratch/walkui/M3/gpairs.py: each cell where the merge differs from W9's recording, and whether L2a made that same move base -> L2a): selregex's four style blocks and fsearch's one move only by L2a's classes: the window and column rows to the page (#b2c3b8 on #1d2824 -> #788079 on #0d1410, the active column's #becfc4 on #314738 too), the reading pane's tint #2c2c0f gone to the focus ground #394440 under the rest tag (full ink #becfc4 -> #cadbd0, the name tint #ecc8f2 kept, its computed words and the blanks after them #becfc4 -> #a1b1a8, the word ink) and under the head on the row below it (text #cadbd0, keys #bada9d -> #add38a bold, dim #79836f -> #8e9d94), a focused reading grip's glyph #000000 -> mode_glyph #06779d, the rail's current tick to the current hit #917a53, a command pane's computed words #b2c3b8 -> #819188; the only pairs L2a's own recordings never made are the same ink moves on cells W9 newly drew there: the head row's gutter cells on the tag's ground (`d` and the body's #e5eee5 on #2c2c0f -> #394440: render's gutter fill on L2a's ground), and fsearch's rest tag on the reading pane W9 moved to row 16 (name tint and words as selregex's); no row neither side explains; the 100 other golden files re-recorded byte for byte as the merge had them (L2a's 36 as L2a recorded them, W9's six text-only goldens as W9 did); GATES (Debug tui, on this change): core-test 1163/1338 (175 skipped; L2a's tree 1160/1335, W9's three new tests), shell-test 1386/1389 (3 skipped), process-test 0 of 103 failed with --update (2 moved, read above); the rest of the gates on the stack's top; load 1.2 to 2.5
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
Diffstat (limited to 'core/Trail.zig')
| -rw-r--r-- | core/Trail.zig | 99 |
1 files changed, 42 insertions, 57 deletions
diff --git a/core/Trail.zig b/core/Trail.zig index cd115018..e10f4fed 100644 --- a/core/Trail.zig +++ b/core/Trail.zig @@ -28,8 +28,7 @@ pub const max_steps = 16; /// The bytes of a step's path or word. A jump to a longer path is no step: /// it opens a pane as `Jumps new-pane` does (look.zig open). pub const max_text = 256; -/// The newest back steps written whole at rest; older ones fold to `·` -/// (§6.3). Out of rest the owner's and the newest alone (`.newest`). +/// The newest back steps written whole; older ones fold to `·` (§6.3). pub const shown_steps = 3; /// `cur` held to the steps there are (walk.zig `.place`). @@ -76,9 +75,15 @@ pub fn isFile(pane: *const Pane) bool { return f.output == null and f.listing == null and !f.pager and f.mini == null and pane.query == null and pane.addon == null; } -/// A pane that walks: a file not held, in a session whose jumps walk. +/// A pane that walks: a file not held, in a session whose jumps walk. A +/// picker's preview in its body changes nothing: its own file, set aside +/// under the preview, is the one asked of (tagline.named: its tag and its +/// tint stay as at rest, UX DESIGN M1). pub fn reading(p: *const Pardes, pane: *const Pane) bool { - return p.settings.jumps == .walk and isFile(pane) and !pane.trail.held; + if (p.settings.jumps != .walk or pane.trail.held) return false; + if (pardes.Pick.landingOf(p, pane) == null) return isFile(pane); + const f = pardes.tagline.named(p, pane) orelse return false; + return f.output == null and f.listing == null and !f.pager and f.mini == null and pane.query == null; } /// An untouched pane (UX J1): a `+New` never typed into (no undo @@ -237,6 +242,9 @@ pub fn replaceStep(p: *Pardes, id: usize, path: []const u8, at: Spot) !usize { /// pane is held, as Keep holds it, and the step opens where a held pane's /// go, in its reader. fn show(p: *Pardes, id: usize, path: []const u8, at: Spot) !usize { + // A step in the pane a picker asks from or previews in ends the picker + // first, as Esc does (UX DESIGN O3): the step is from its own text. + pardes.Pick.yieldFor(p, id); const pane = p.panes[id].?; if (pane.file) |f| if (std.mem.eql(u8, f.path, path)) { look.clearNavigationSelection(p, pane); @@ -457,9 +465,7 @@ pub fn sayBack(p: *Pardes, id: usize) void { // ---- the words ---- -/// `newest`: out of rest (UX D1), the owner's word and the newest back -/// step's alone, each with the separator after it. -pub const Part = enum { back, forward, newest }; +pub const Part = enum { back, forward }; /// Step `i`'s word: `‹@p3`, `rank.zig:14`, a list's, search's or recipe's /// own text. A place's file is named by its basename, or where another @@ -505,7 +511,7 @@ pub fn backs(t: *const Trail) usize { /// The steps a part writes. fn range(t: *const Trail, part: Part) [2]usize { return switch (part) { - .back, .newest => .{ 0, t.backs() }, + .back => .{ 0, t.backs() }, .forward => .{ @min(t.n, t.cur + 1), t.n }, }; } @@ -522,7 +528,6 @@ pub const shown_ahead = 2; fn folds(t: *const Trail, part: Part, whole: usize, i: usize) bool { const end = t.backs(); return switch (part) { - .newest => false, .forward => t.steps[i] == .place and i > t.cur + shown_ahead, .back => i + whole < end and switch (t.steps[i]) { .place => true, @@ -541,42 +546,26 @@ fn runStart(t: *const Trail, part: Part, whole: usize, i: usize) usize { return at; } -/// The cells of the newest step's word out of rest: a longer one is cut -/// in its middle (UX D1: `Find pick…3/6`). -const newest_cells = 24; - /// Step `i`'s word as `part` writes it, null where it writes none: a -/// folded step's is the fold's `+N` on its first, none on the others; out -/// of rest the owner's and the newest step's alone, a word longer than -/// `newest_cells` keeping its first and last cells around a `…`. -fn wordIn(t: *const Trail, part: Part, whole: usize, i: usize, buf: *[max_text + 16]u8, cut: *[max_text + 16]u8) ?[]const u8 { - if (part == .newest and t.steps[i] != .owner and i + 1 != t.backs()) return null; +/// folded step's is the fold's `+N` on its first, none on the others. +fn wordIn(t: *const Trail, part: Part, whole: usize, i: usize, buf: *[max_text + 16]u8) ?[]const u8 { if (folds(t, part, whole, i)) { if (runStart(t, part, whole, i) != i) return null; var end = i; while (end < range(t, part)[1] and folds(t, part, whole, end)) end += 1; return std.fmt.bufPrint(buf, "+{d}", .{end - i}) catch unreachable; // a count fits } - const word = wordOf(t, i, buf); - if (part != .newest or word.len <= newest_cells) return word; - const tab = 8; // a step's word holds no tab - if (panes.File.displayWidth(tab, word) <= newest_cells) return word; - const head = panes.File.byteAtDisplay(tab, word, newest_cells / 2); - var tail = word.len; - while (tail > head and panes.File.displayWidth(tab, word[tail..]) < newest_cells / 2 - 1) tail = modal.prevGrapheme(word, tail); - return std.fmt.bufPrint(cut, "{s}…{s}", .{ word[0..head], word[tail..] }) catch word; + return wordOf(t, i, buf); } /// The back steps' words, each with the separator after it (before the /// path), or the forward steps', each with one before it (after the path), -/// each run of folded ones as one `+N` (`folds`); out of rest (`newest`) the -/// owner's and the newest's. +/// each run of folded ones as one `+N` (`folds`). pub fn write(t: *const Trail, part: Part, whole: usize, w: *std.Io.Writer) std.Io.Writer.Error!void { var buf: [max_text + 16]u8 = undefined; - var cut: [max_text + 16]u8 = undefined; const r = range(t, part); - for (r[0]..r[1]) |i| if (wordIn(t, part, whole, i, &buf, &cut)) |word| switch (part) { - .back, .newest => try w.print("{s}" ++ sep, .{word}), + for (r[0]..r[1]) |i| if (wordIn(t, part, whole, i, &buf)) |word| switch (part) { + .back => try w.print("{s}" ++ sep, .{word}), .forward => try w.print(sep ++ "{s}", .{word}), }; } @@ -584,10 +573,9 @@ pub fn write(t: *const Trail, part: Part, whole: usize, w: *std.Io.Writer) std.I /// The bytes `write` writes for `part`. pub fn bytes(t: *const Trail, part: Part, whole: usize) usize { var buf: [max_text + 16]u8 = undefined; - var cut: [max_text + 16]u8 = undefined; var n: usize = 0; const r = range(t, part); - for (r[0]..r[1]) |i| if (wordIn(t, part, whole, i, &buf, &cut)) |word| { + for (r[0]..r[1]) |i| if (wordIn(t, part, whole, i, &buf)) |word| { n += word.len + sep.len; }; return n; @@ -604,9 +592,8 @@ pub fn walked(t: *const Trail) ?u8 { return null; } -/// Whether pane `pane`'s tag is out of rest in the live view (UX D1: its -/// path, its forward steps and its own words hidden, the owner and the -/// newest step before the head). Asking is rest. +/// Whether pane `pane`'s tag is out of rest in the live view: its head and +/// band hang under it, over its body (UX DESIGN I1, M2). Asking is rest. pub fn outOfRest(p: *const Pardes, pane: *const Pane) bool { const host = TagState.hostOf(p) orelse return false; return p.panes[host] == pane; @@ -616,13 +603,12 @@ pub fn outOfRest(p: *const Pardes, pane: *const Pane) bool { /// what `write` writes for the back steps, the newest `whole` whole. pub fn spanOf(t: *const Trail, i: usize, whole: usize) [2]usize { var buf: [max_text + 16]u8 = undefined; - var cut: [max_text + 16]u8 = undefined; const at = if (folds(t, .back, whole, i)) runStart(t, .back, whole, i) else i; var x: usize = 0; - for (0..at) |j| if (wordIn(t, .back, whole, j, &buf, &cut)) |word| { + for (0..at) |j| if (wordIn(t, .back, whole, j, &buf)) |word| { x += word.len + sep.len; }; - const word: []const u8 = wordIn(t, .back, whole, at, &buf, &cut) orelse ""; + const word: []const u8 = wordIn(t, .back, whole, at, &buf) orelse ""; return .{ x, x + word.len }; } @@ -635,11 +621,10 @@ pub fn isFolded(t: *const Trail, i: usize, whole: usize) bool { /// for it, null on a separator or past them. pub fn stepAt(t: *const Trail, part: Part, whole: usize, off: usize) ?u8 { var buf: [max_text + 16]u8 = undefined; - var cut: [max_text + 16]u8 = undefined; var x: usize = 0; const r = range(t, part); for (r[0]..r[1]) |i| { - const word = wordIn(t, part, whole, i, &buf, &cut) orelse continue; + const word = wordIn(t, part, whole, i, &buf) orelse continue; if (part == .forward) x += sep.len; // A fold's `+N` is the step nearest the path of those it holds. if (off >= x and off < x + word.len) { @@ -969,10 +954,12 @@ test "the walk drawn with a picker's list and the notice row (walk UI G 2e, SPEC f.look(f.held, "rank.zig", 12); const r = p.view().active; // A list asked from the held pane (SPC e's places, a server's answer): - // its Enter lands in the reader, nothing made. + // hung under the held pane's tag (UX DESIGN O1), its Enter lands in the + // reader, nothing made. const rows = try std.fmt.bufPrint(&buf, "{s}/place.zig:8:1 of\n{s}/place.zig:40:1 Span\n", .{ f.dir, f.dir }); pardes.Pick.open(p, f.held, .list, "Refs", "", rows); - try std.testing.expectEqual(p.panes[r].?.serial, p.view().tag_state.host); + try std.testing.expectEqual(owner, p.view().tag_state.host); + try std.testing.expectEqual(p.panes[r].?.serial, pardes.Pick.live(p).?.landing); pardes.Pick.landHere(p); p.sync(); // The reader stepped (to another file: a pane of its own, its owner's @@ -1180,7 +1167,7 @@ test "a band on a walked reading pane is whole: the layout's floor counts its ta try std.testing.expect(at.band > 0); try std.testing.expectEqual(pardes.Band.takes(p, r), at.band); try std.testing.expectEqual(layout.wantedTagRows(p, r), pane.tag_rows); - try std.testing.expect(v.rects[r].h >= @max(pane.tag_rows, at.text + at.band)); + try std.testing.expect(v.rects[r].h >= at.tag + at.over); p.update(.{ .key = .{ .cp = pardes.Key.escape } }); p.sync(); try std.testing.expect(pardes.TagState.hostOf(p) == null); @@ -1301,7 +1288,7 @@ test "Jumps new-pane jumps as before the walk: a new pane for a file no pane sho try std.testing.expectEqual(open + 2, now); } -test "Enter on a word of the walk, the keyboard in the tag, goes back to its step as a click does; out of rest the walk folds to its newest word" { +test "Enter on a word of the walk, the keyboard in the tag, goes back to its step as a click does; out of rest the walk is as at rest, its words its steps (UX DESIGN M1)" { var f: Fixture = .{ .p = undefined, .tmp = undefined }; try f.init(60); defer f.deinit(); @@ -1314,35 +1301,33 @@ test "Enter on a word of the walk, the keyboard in the tag, goes back to its ste var at: [64]u8 = undefined; const rest = try std.fmt.bufPrint(&buf, "‹@p{d} › rank.zig:10 › rank.zig:20 › {s}/rank.zig Keep", .{ owner, f.dir }); try std.testing.expect(std.mem.startsWith(u8, try tagOf(p, pane), rest)); - // SPC, its level shown: out of rest the tag is the owner, the newest - // step and the head (UX D1): no older step, no path, no Keep, none of - // its own words; back at rest, as they were. + // SPC, its level shown: out of rest the tag is as at rest, every step, + // the path and Keep, the head under it (UX DESIGN M1); each word its + // step. const whole_rest = try p.gpa.dupe(u8, try tagOf(p, pane)); defer p.gpa.free(whole_rest); p.update(.{ .key = .{ .cp = ' ' } }); p.advance(p.clock.now_ns); p.clock.now_ns = p.view().tag_state.due_ns; p.sync(); - var folded_buf: [4096 + 128]u8 = undefined; + try std.testing.expect(pardes.TagState.hostOf(p) == r); const out = try tagOf(p, pane); - try std.testing.expect(std.mem.startsWith(u8, out, try std.fmt.bufPrint(&folded_buf, "‹@p{d} › rank.zig:20 › ␣ ▸ ", .{owner}))); - try std.testing.expect(std.mem.indexOf(u8, out, "rank.zig:10") == null and std.mem.indexOf(u8, out, f.dir) == null and std.mem.indexOf(u8, out, "Keep") == null); - // Look on the newest step's word is that step. + try std.testing.expectEqualStrings(whole_rest, out); try std.testing.expectEqual(@as(?u8, pane.trail.cur - 1), pardes.tagline.trailAt(p, pane, std.mem.indexOf(u8, out, "rank.zig:20").? + 3)); try std.testing.expectEqual(@as(?u8, 0), pardes.tagline.trailAt(p, pane, 1)); p.update(.{ .key = .{ .cp = pardes.Key.escape } }); try std.testing.expectEqualStrings(whole_rest, try tagOf(p, pane)); - // Back a step (a forward step after the path at rest): out of rest the - // forward step is hidden as the path is. + // Back a step: the forward step after the path, out of rest as at rest. pardes.Trail.lookStep(p, r, pane.trail.cur - 1); p.sync(); - try std.testing.expect(std.mem.indexOf(u8, try tagOf(p, pane), "rank.zig:30") != null); + const back = try p.gpa.dupe(u8, try tagOf(p, pane)); + defer p.gpa.free(back); + try std.testing.expect(std.mem.indexOf(u8, back, "rank.zig:30") != null); p.update(.{ .key = .{ .cp = ' ' } }); p.advance(p.clock.now_ns); p.clock.now_ns = p.view().tag_state.due_ns; p.sync(); - try std.testing.expect(std.mem.startsWith(u8, try tagOf(p, pane), try std.fmt.bufPrint(&folded_buf, "‹@p{d} › rank.zig:10 › ␣ ▸ ", .{owner}))); - try std.testing.expect(std.mem.indexOf(u8, try tagOf(p, pane), "rank.zig:30") == null); + try std.testing.expectEqualStrings(back, try tagOf(p, pane)); p.update(.{ .key = .{ .cp = pardes.Key.escape } }); pardes.Trail.lookStep(p, r, pane.trail.cur + 1); p.sync(); |
