diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-26 09:40:17 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-26 10:28:44 -0300 |
| commit | 8d90edcec1ba432d0f67ecc3a79eb6bf193369ff (patch) | |
| tree | 2adbc108fb6d5076f9dba35afe850d14644ff801 /core/Trail.zig | |
| parent | 8959b031dc330b4da21c0e89e0831d6fadbcd757 (diff) | |
| download | pardes-8d90edcec1ba432d0f67ecc3a79eb6bf193369ff.tar.gz pardes-8d90edcec1ba432d0f67ecc3a79eb6bf193369ff.zip | |
TagState, tagline, Band, draw, layout, mouse, Pick, Trail, Core: out of rest a pane's tag stays exactly as at rest and what the keyboard drives hangs under it, the head on the row under the tag's rows, then the band (UX DESIGN M, binding; the user, looking at a picker started in an empty pane whose tag had become `^ ␣ f Find ascii 1/1`: "doesn't it make sense to the search just show below the tagline instead of being search tagline then results?", then "Keep consistent, idk, yes"): for every state the keyboard drives (rolled and unrolled levels, `"`, Help, describe-key, every picker, every text prompt, `:`, rename, code actions) the tag keeps its mark, owner, trail, path, Keep, computed words and own text, its rows and its wrapping, the box alone saying `^` while typing; THE WAY IT WAS: the head (TagState.head) was the tag's text after a cut-down prefix (D1's owner and newest step, tagline.pathPrefix's out-of-rest branch, Trail's `.newest` part), so the path, Keep and the user's text left the screen while you typed, the key cells sat on the tag's row for a level and jumped with it, and a picker's preview in a reading pane would have named the previewed file had the path stayed; THE CHANGE: TagState.head is the head alone, laid out from the tag's text column on rows of its own (Builder's `lead` gone), and TagState.asking the question a tag says, which stays in the tag (UX D13, M1: questions unchanged); tagline.shownTail is the question or the own text in every state, pathPrefix the path in every state (the out-of-rest branch and Trail's `.newest` part, `newest_cells` and the `cut` buffers deleted); a pane a picker previews in names its own file, the one Pick.showText set aside (tagline.named, tagWords, and Trail.reading asking the same file, so its tint, Keep and words are the rest ones); a pane made for the picker (it has no rest) shows its owner's word alone, `‹@pN ›` (M3; P1's reading 2 reversed); Band.covered is the tag's rows at rest, then the head's rows, then the band's, `over` = head + band (no rows the head reused: M4), layout.headRows the head's own rows and floorRows the tag's rows plus the head's and the band's (a head that does not fit borrows from its column as a band does); draw.zig joinBand paints the head's rows as the band layer's first rows (its spans' inks moved there from paintPaneTag, its caret the band layer's cursor), the band's under them, the spines from the head's key cells on its own row; render draws the host's tag with its rest rows; mouse: a press on a tag out of rest ends its state as Esc does and then does what it does at rest (M3; a pane made for a picker goes with it and the press with it), bandPoint reads the head's rows as the band layer's first, and B1 in the head's field puts the field's caret there; edit.zig refuses an edit of a tag only while it asks; RUN (TEST FIRST): five new tests, each failing on the base (M2, 8959b031dc33) and passing now: TagState "out of rest a tag is drawn as at rest, the head hanging under it ..." (a `.list` picker in a reading pane that walked near.txt -> far.txt: the tag's rows cell for cell as at rest but the box, its path far.txt while the body previews near.txt, the head `␣ l Refs ... 1/1` on the next row, its count the row's last cells, the band under it; Esc, the rows as before: failed on the base at the tag text, `near.txt:2 › ␣ l Refs ...`), TagState "the key cells are one thing growing on the row under the tag ..." (`␣`, `␣ f`, `␣ f Find` in the same cells of the row under a two-row tag: failed on the base, `␣` on the tag's row), TagState "a click that gives the keyboard to another pane ends a level ...; one in the level's own tag ends it too, then does what it does there at rest ..." (was "... one in the level's own tag keeps it"; B1 on the tag's own word ends SPC's level and gives the tag the keyboard, B2 on `Wrap` ends Help and toggles wrap: failed on the base, the level kept), Pick "a pane made for a picker has no rest: its tag is its owner's word alone, `‹@pN ›` ..." (B3 on it: the picker ends, the made pane goes, nothing under the press looked at: failed on the base, its tag `␣ f Find ...`), Command ": hangs its field under the tag, which stays as at rest; `:` on the empty field gives the keyboard to that tag's own text right above it ..." (failed on the base, the tag text `: ...`); the expectations that read the head through the tag's text read it from TagState.head now (TagState's testTag, Prompt's and Command's headOf, Pick's headOf; bindings, Messages, lsp/Ask, Trail, Band, draw, views: ~40), and the ones that read a body's first row while a prompt is up read the rows under the head's (Prompt's `/`, `s`, `|` tests, body_layer's current-place test, Ask's rename); views' short-column picker test runs at 15 rows (the head's row is one more covered row: at 12 the band had none left); the process test msg waits for the second reload by the notice row's `×2` (the pane's one line is under the `s` prompt's head now); AND A FAULT THIS MADE VISIBLE: code actions drew their edit's ghost lines from the body's top under a band drawn over it (Pick.previewing was a place's preview alone), so an edit on the first rows of a file was under the band; with the head's row one more covered row, test/behaviour/language_servers.zig's "SPC l a lists the server's code actions ..." failed (`let x = sum(1, 2);` at line 4 under the head and a 4-row band, not on the screen); THE FIX: code actions' body is their preview from the first (UX DESIGN I1: "a picker and code actions (whose body is the preview) keep D6"): Pick.previewing is true for them, so the body starts under the head and the band as a picker's preview does; the behaviour test passes now; GATES (Debug tui, this change): core-test 1166/1340 (174 skipped; M2's gate 1155/1329), shell-test 1381/1384 (3 skipped), behaviour-test 287/287 and --replay 287/287, pane-test 184/185 (1 skipped), term-test 17/17, kitty-test 45/45 (these three before the code-actions fix and two renames), process-test 8 of 149 failed (3 skipped): exactly the goldens with a frame out of rest (find, fsearch, leader, lsp, msg, pipe, selregex, ttyhelp), re-recorded and explained by the next change; the dump does not change (no pane or view field); no frame or perf gate (the user's rule of 2026-11-26); load 4.2 to 14.3
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 | 90 |
1 files changed, 35 insertions, 55 deletions
diff --git a/core/Trail.zig b/core/Trail.zig index e42ab1e2..e07e4357 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 @@ -457,9 +462,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 +508,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 +525,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 +543,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 +570,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 +589,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 +600,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 +618,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) { @@ -1175,7 +1157,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); @@ -1296,7 +1278,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(); @@ -1309,35 +1291,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(); |
