From 7d0aaa0c1e68127c023358698498eaeffe57401b Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 26 Nov 2026 10:10:33 -0300 Subject: draw: while a pane's body previews a file not its own (a picker's preview: its own text set aside, or a kind shown over it), its tag's path is drawn in the tag's dim ink, because the tag names a file the body is not showing (the coordinator's ruling, built as the default and offered to the user, who has not answered: UX DESIGN part M, M7.2's "the fix is an ink, not a layout"); its own file under the picker's cursor, or the picker gone, the path in its inks again; ONE HUNK in paintPaneTag, after the name's tint, so it is easy to take back; today a previewing pane hosts its picker and is out of rest, its path not drawn, so the hunk shows once W5 (the field under the tag, part M) keeps that tag at rest; RUN (TEST FIRST): draw.zig "while a pane's body previews a file not its own, its tag's path is dim ..." opens a Refs list from a reading pane (alpha.zig) and, its tag state hosted by another pane as a picker under a tag at rest will be, asks the path's first and last cells in the focused tag's dim while beta.zig previews, in the full ink and the name's tint once its own alpha.zig is under the cursor, and in the full ink after Esc: fails without the hunk (the full ink), passes with it; GATES (tui): core-test 1155/1329 (174 skipped), process-test 0 of 149 failed (3 skipped; no golden moves: no golden holds a tag at rest over a preview); load 4.7 to 14.8 (other agents' builds) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE --- core/draw.zig | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/core/draw.zig b/core/draw.zig index 822bfb67..0946978f 100644 --- a/core/draw.zig +++ b/core/draw.zig @@ -1121,6 +1121,15 @@ fn paintPaneTag(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, } if (tagTintRange(p, pane, first_line, prefix_len)) |name| if (name.lo < name.hi) inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, name.lo, @min(name.hi, first_line.len), chrome.name[@intFromEnum(g)], false); + // While its body previews a file not its own (a picker's: its own set + // aside, or a kind shown over it), its path names a file the body is + // not showing: the dim ink (the coordinator's ruling, UX DESIGN M7.2). + if (pardes.Pick.previewing(p, id)) if (pardes.Pick.live(p)) |pk| { + const own = if (pk.aside) |f| f.path else if (pane.file) |f| f.path else ""; + const body = if (pane.addon) |k| k.path else if (pane.file) |f| f.path else ""; + if (!std.mem.eql(u8, own, body)) if (tagTintRange(p, pane, first_line, prefix_len)) |name| + inkTag(p, s, shown, lines[0..rows], top, tx, tag_y, tw, tagline.nameAt(p, pane), @min(name.hi, first_line.len), inks.dim, false); + }; // A walk's forward steps, after the name, dimmed (Trail.zig); its fold // `+N` too; the word n walks underlined in the key ink (UX D8). const ahead = tagline.forwardSpan(p, pane); @@ -1953,3 +1962,65 @@ test "a reading pane's tag is on the plain or the focused ground, as a held one' }; } } + +test "while a pane's body previews a file not its own, its tag's path is dim: it names a file the body is not showing (the coordinator's ruling, UX DESIGN M7.2); its own file previewed, or the picker gone, the path in its inks again" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 140, .rows = 40 }); + defer p.deinit(); + p.settings.jumps = .walk; + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + for ([_][]const u8{ "alpha.zig", "beta.zig" }) |name| try tmp.dir.writeFile(std.testing.io, .{ .sub_path = name, .data = "one\ntwo\n" }); + var base_buf: [std.Io.Dir.max_path_bytes]u8 = undefined; + const dir = base_buf[0..try tmp.dir.realPath(std.testing.io, &base_buf)]; + const a_path = try std.Io.Dir.path.join(std.testing.allocator, &.{ dir, "alpha.zig" }); + defer std.testing.allocator.free(a_path); + pardes.look.lookAt(p, p.view().active, a_path); + p.sync(); + const id = p.view().active; + const pane = p.panes[id].?; + p.newScratchBelow(id); + const other = p.view().active; + p.view().active = id; + pardes.Pick.open(p, id, .list, "Refs", "", "beta.zig:2:1 two\nalpha.zig:1:1 one\n"); + for (0..4) |_| { + pardes.Stream.step(p); + p.update(.tick); + } + try std.testing.expect(pardes.Pick.previewing(p, id) and std.mem.endsWith(u8, pane.file.?.path, "beta.zig")); + var frame = std.heap.ArenaAllocator.init(std.testing.allocator); + defer frame.deinit(); + const Path = struct { + // The tag at rest (its tag state hosted by another pane, as a + // picker under a tag at rest is): the ink of its path's first and + // last cells. + fn inks(q: *Pardes, a: std.mem.Allocator, at: usize, away: usize) ![2]Color { + const host = q.view().tag_state.host; + q.view().tag_state.host = q.panes[away].?.serial; + defer q.view().tag_state.host = host; + const s = try q.render(a); + const t = q.panes[at].?; + const r = q.view().rects[at]; + const lo = tagline.nameAt(q, t); + const path = t.file.?.path; + const x = r.x + TAG_TEXT_INSET + @as(u16, @intCast(panes.File.displayWidth(q.settings.tab, (try tagline.tagText(q, a, t))[0..lo]))); + return .{ s.at(x, r.y).style.fg, s.at(x + @as(u16, @intCast(panes.File.displayWidth(q.settings.tab, path))) - 1, r.y).style.fg }; + } + }; + const inks = p.chrome().on(.focus); + for (try Path.inks(p, frame.allocator(), id, other)) |ink| try std.testing.expectEqual(Color{ .rgb = inks.dim }, ink); + // Its own file under the cursor: the path names what the body shows. + p.update(.{ .key = .{ .cp = pardes.Key.down } }); + for (0..4) |_| { + pardes.Stream.step(p); + p.update(.tick); + } + try std.testing.expectEqualStrings(a_path, pane.file.?.path); + var got = try Path.inks(p, frame.allocator(), id, other); + try std.testing.expectEqual(Color{ .rgb = inks.text }, got[0]); + try std.testing.expectEqual(Color{ .rgb = p.chrome().name[1] }, got[1]); + // The picker gone: its own again. + p.update(.{ .key = .{ .cp = pardes.Key.escape } }); + try std.testing.expect(!pardes.Pick.previewing(p, id)); + got = try Path.inks(p, frame.allocator(), id, other); + try std.testing.expectEqual(Color{ .rgb = inks.text }, got[0]); +} -- cgit v1.3