summaryrefslogtreecommitdiff
path: root/core/Trail.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 04:58:53 -0300
committerGabriel Schneider <[email protected]>2026-11-25 05:18:54 -0300
commit920aaa6e6c2317aa775937b01f727fa9418b7db2 (patch)
tree1cb02617ddfbe59712717e9ecb60ad766bf743ee /core/Trail.zig
parent3c4b2c99b1a969abad0a530fa99b70b2cb564af3 (diff)
downloadpardes-920aaa6e6c2317aa775937b01f727fa9418b7db2.tar.gz
pardes-920aaa6e6c2317aa775937b01f727fa9418b7db2.zip
tagline, Trail, Core, layout: the tag out of rest is the owner's word, the newest step's and the head, nothing else (walk UI polish P1, UX DESIGN.md D1, the coordinator's R1-CORRECTED: the user's "why the tagline is still showing the regular tagline text?"): out of rest the path, Keep, the forward steps, the progress and the tag's own words were drawn before the head, so the key cells and the band's spines hung 40-50 columns in (shot 02's spines at column 50) and a picker's tag named the PREVIEWED file as the pane's own (shot 04: `/tmp/.../core/Store.zig ␣ f Find re 2/3`); now `‹@p1 › rank.zig:20 › ␣ ▸ b buffer…`, the head from the tag's first text column when there is no walk (`␣ f Find re`), the spines at columns 2-4; THE CHANGE: Trail.Part `.newest` writes the owner's word and the newest back step's alone, each with ` › `, a word past 24 cells cut in its middle with `…` (D1 item 4), and `stepAt(.newest)` maps a Look or Exec on any of its cells to that step; tagline.pathPrefix returns it while Trail.outOfRest (the live view's host is the pane: asking is rest and keeps its path), the old body now `restPath`; `restPrefix`, the prefix as at rest whatever the state, is what Core.sync measures `tag_lead` by (the tag's cursor and selections are offsets in its text at rest: a head over its own text moves none of them; on the shown prefix they were shifted by the path's length and back, and `| in a tag pipes the tag's own text` piped 4 wrong bytes) and what layout.wantedTagRows counts the rest rows with (a tag out of rest keeps them at least); the heads no longer lead with a space (TagState's Help/Keys/Rename/level, Pick.head, Prompt.head: the out-of-rest prefix ends in its own ` › `); no name tint, forward-step ink, unlit search word or progress out of rest (draw.zig tagTintRange, paintPaneTag; Prompt.unlit); tagline.onName and forwardSpan are off out of rest; `Trail.folded` is gone (it only told out of rest, now `.newest`: at rest it is `shown_steps`), `nameAt` takes no Pardes; TEST FIRST: Trail.zig "Enter on a word of the walk ...": out of rest `‹@pN › rank.zig:20 › ␣ ▸ ` with no older step, no directory, no Keep (on the base `‹@pN › · › rank.zig:20 › <dir>/rank.zig`: fails), a step back hides its forward step out of rest, Look maps the newest word and the owner's to their steps, and the tag at rest byte-identical after Esc; Pick.zig's reader test: the picker's head starts the tag's text (`␣ f Find pick 1/1`), no previewed path; the heads' other tests drop their leading space; test/behaviour keys.zig's prompt case reads the tag file out of rest as the head alone (`s zq`, no `/test.txt`); behaviour-test 277/277; core-test 1062/1232 (170 skipped); process-test: 8 goldens regenerated and read, each changed row the out-of-rest tag with no path (leader, pipe, msg, selregex, find, fsearch, lsp, ttyhelp: the band's spines at columns 2-4, the steps right of them, the rows no longer pushed onto a second tag row; msg's `s EXT` head and fsearch's `/` head still wrap their hints mid-word: D3's); a user meets it in every state out of rest
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.zig93
1 files changed, 76 insertions, 17 deletions
diff --git a/core/Trail.zig b/core/Trail.zig
index 9223d1d3..58a72256 100644
--- a/core/Trail.zig
+++ b/core/Trail.zig
@@ -15,6 +15,7 @@ const config = @import("config.zig");
const layout = @import("layout.zig");
const panes = @import("panes.zig");
const look = @import("look.zig");
+const modal = @import("modal.zig");
const Pardes = pardes.Pardes;
const Pane = panes.Pane;
const Spot = look.Spot;
@@ -27,7 +28,8 @@ 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; older ones fold to `·` (§6.3).
+/// 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`).
pub const shown_steps = 3;
/// `cur` held to the steps there are (walk.zig `.place`).
@@ -311,7 +313,9 @@ pub fn walkBy(p: *Pardes, id: usize, delta: i32) bool {
// ---- the words ----
-pub const Part = enum { back, forward };
+/// `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 };
/// Step `i`'s word: `‹@p3`, `rank.zig:14`, a list's, search's or recipe's
/// own text; `·` when it is folded.
@@ -331,19 +335,43 @@ const sep = " › ";
/// The steps a part writes.
fn range(t: *const Trail, part: Part) [2]usize {
return switch (part) {
- .back => .{ 0, t.cur },
+ .back, .newest => .{ 0, t.cur },
.forward => .{ @min(t.n, t.cur + 1), t.n },
};
}
+/// Whether step `i` is in what `part` writes: out of rest the owner and
+/// the newest back step only.
+fn writes(t: *const Trail, part: Part, i: usize) bool {
+ return part != .newest or t.steps[i] == .owner or i + 1 == t.cur;
+}
+
+/// 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: out of rest a word longer than
+/// `newest_cells` keeps its first and last cells around a `…`.
+fn shownWord(t: *const Trail, part: Part, i: usize, whole: usize, buf: *[max_text + 16]u8, cut: *[max_text + 16]u8) []const u8 {
+ const word = wordOf(t, i, whole, 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;
+}
+
/// 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):
/// the newest `whole` back steps whole, older ones `·` (`folded`).
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| switch (part) {
- .back => try w.print("{s}" ++ sep, .{wordOf(t, i, whole, &buf)}),
+ for (r[0]..r[1]) |i| if (writes(t, part, i)) switch (part) {
+ .back, .newest => try w.print("{s}" ++ sep, .{shownWord(t, part, i, whole, &buf, &cut)}),
.forward => try w.print(sep ++ "{s}", .{wordOf(t, i, whole, &buf)}),
};
}
@@ -351,18 +379,21 @@ 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| n += wordOf(t, i, whole, &buf).len + sep.len;
+ for (r[0]..r[1]) |i| if (writes(t, part, i)) {
+ n += shownWord(t, part, i, whole, &buf, &cut).len + sep.len;
+ };
return n;
}
-/// The back steps pane `pane`'s tag writes whole: `shown_steps` at rest,
-/// the newest alone while its tag is out of rest (SPEC §3.4.3), so a
-/// state's head and the band's spines keep their room.
-pub fn folded(p: *const Pardes, pane: *const Pane) usize {
- const host = TagState.hostOf(p) orelse return shown_steps;
- return if (p.panes[host] == pane) 1 else shown_steps;
+/// 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.
+pub fn outOfRest(p: *const Pardes, pane: *const Pane) bool {
+ const host = TagState.hostOf(p) orelse return false;
+ return p.panes[host] == pane;
}
/// Where back step `i`'s word is in what `write` writes for the back
@@ -378,14 +409,16 @@ pub fn spanOf(t: *const Trail, i: usize, whole: usize) [2]usize {
/// 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| {
+ if (!writes(t, part, i)) continue;
if (part == .forward) x += sep.len;
- const n = wordOf(t, i, whole, &buf).len;
+ const n = shownWord(t, part, i, whole, &buf, &cut).len;
if (off >= x and off < x + n) return @intCast(i);
x += n;
- if (part == .back) x += sep.len;
+ if (part != .forward) x += sep.len;
}
return null;
}
@@ -841,12 +874,38 @@ 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: out of rest, the older steps are `·`, the owner and the newest
- // whole; back at rest, as they were.
+ // 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.
+ 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(std.mem.startsWith(u8, try tagOf(p, pane), try std.fmt.bufPrint(&folded_buf, "‹@p{d} › · › rank.zig:20 › {s}/rank.zig", .{ owner, f.dir })));
+ 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.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.
+ 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);
+ 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);
p.update(.{ .key = .{ .cp = pardes.Key.escape } });
+ pardes.Trail.lookStep(p, r, pane.trail.cur + 1);
+ p.sync();
try std.testing.expect(std.mem.startsWith(u8, try tagOf(p, pane), rest));
// The keyboard in the tag, its cursor on `rank.zig:10`: Enter goes back
// to that step, the keyboard in the body again.