summaryrefslogtreecommitdiff
path: root/core/Pick.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-26 12:44:35 -0300
committerGabriel Schneider <[email protected]>2026-11-26 13:02:49 -0300
commit51f211d694beff9a389ab519f2286cef077adb81 (patch)
tree2df93ee551f2820011f6f67b32f5131fbd927888 /core/Pick.zig
parent3d60aa05ec1a6f9ed535186be6c6c2850c71b24d (diff)
parentd7b01dfc187244b6613a954d82552675d3bd2689 (diff)
downloadpardes-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/Pick.zig')
-rw-r--r--core/Pick.zig512
1 files changed, 381 insertions, 131 deletions
diff --git a/core/Pick.zig b/core/Pick.zig
index c39e8ec9..6899f607 100644
--- a/core/Pick.zig
+++ b/core/Pick.zig
@@ -1,11 +1,12 @@
//! A picker (pick-ui SPEC.md §5, direction E): a list of places, panes or
-//! names unrolled in the tag of the pane its Enter lands in (§3.5): the
-//! asking pane when it reads, else its reader, made for the picker when it
-//! has none and taken away again by Esc. Its query is typed in that tag's
-//! field (TagState.field), its rows hang in the band under it (Band.zig)
-//! eleven at a time around the cursor, and that pane's body is the preview:
-//! the current row's file at its line, its own text set aside meanwhile and
-//! put back when the picker rolls up.
+//! names hung under the tag of the pane that asked, which keeps the
+//! keyboard (UX DESIGN O1). Its query is typed in the head's field
+//! (TagState.field), its rows hang in the band under it (Band.zig) eleven
+//! at a time around the cursor, and the body of the pane its Enter lands in
+//! is the preview: the current row's file at its line, its own text set
+//! aside meanwhile and put back when the picker rolls up. That pane is the
+//! asking one when it reads or is untouched, else its reader, else free
+//! space, else one made under it for the picker and taken away by Esc.
//!
//! The rows are Query.zig's producers', re-presented: names scored by
//! Names.zig a frame's count at a time (Find's listing from the disk
@@ -93,17 +94,22 @@ word: Kind.Buf(24) = .{},
keys: Kind.Buf(4) = .{},
/// Where Find and Grep look; what the rows' paths are relative to.
dir: Kind.Buf(4096) = .{},
-/// The pane that asked, and the one its Enter lands in, by serial.
+/// The pane that asked, under whose tag it hangs, and the one its Enter
+/// lands in, whose body previews, by serial.
owner: u32 = 0,
landing: u32 = 0,
/// The landing pane was made for it: Esc takes it away.
made: bool = false,
-/// Its band's rows at most: 40 % of its host pane's rows at open (UX D6),
+/// Its band's rows at most: 40 % of its asking pane's rows at open (UX D6),
/// fixed: the layout that borrows the host's body from its column reads
/// it, and a pane laid out again changes it no more than typing does.
cap: u16 = 0,
/// Unrolled in a view's tag now.
unrolled: bool = false,
+/// The most rows its list has had since it unrolled, eleven at most: its
+/// band grows with a list whose rows come later and never shrinks while it
+/// is up (bandRows, UX D6).
+tall: u8 = 0,
names: Names = .{},
/// A Grep's lines, as the disk engine sends them (Query.take).
found: std.ArrayList(Query.Found) = .empty,
@@ -209,16 +215,39 @@ pub fn live(p: *const Pardes) ?*Pick {
/// band (Pardes.sync), as a file's first lines could not be put under it
/// otherwise (UX DESIGN I1's "a picker's landing line at a third below
/// the band" for Find's line 1: W1's reading); before that, and at rest
-/// again, the pane's own text stays where it was under the band.
+/// again, the pane's own text stays where it was under the band. Code
+/// actions' body is their preview from the first, their edit's ghost lines
+/// in it (UX DESIGN I1: "a picker and code actions (whose body is the
+/// preview) keep D6"): under the head and the band, never under them.
pub fn previewing(p: *const Pardes, id: usize) bool {
const pk = live(p) orelse return false;
const pane = p.panes[id] orelse return false;
- return pk.previewed and pane.serial == pk.landing;
+ return (pk.previewed or pk.source == .actions) and pane.serial == pk.landing;
}
-/// A picker of `source` asked from pane `from`, unrolled in the tag of the
-/// pane its Enter will land in (SPEC §3.5), its field `query`. `rows` are
-/// a list's (`source` `list`, titled `word`).
+/// Whether pane `id` shows the live picker's preview, being its landing
+/// pane, for the layout: a body of 60 % kept under what is above it (UX
+/// D6, DESIGN O1), the head and the band among that when it asked too.
+/// Panes and Themes preview in no pane.
+pub fn previewPane(p: *const Pardes, id: usize) bool {
+ const pk = live(p) orelse return false;
+ const pane = p.panes[id] orelse return false;
+ return pane.serial == pk.landing and pk.source != .panes and pk.source != .themes;
+}
+
+/// The live picker whose rows pane `pane`'s body previews, it being its
+/// landing pane: what its tag names in place of the preview
+/// (tagline.named, UX DESIGN M3); none for a themes or actions picker,
+/// whose landing is the asking pane's own text.
+pub fn landingOf(p: *const Pardes, pane: *const Pane) ?*const Pick {
+ const pk = live(p) orelse return null;
+ if (pk.landing != pane.serial or pk.source == .themes or pk.source == .actions) return null;
+ return pk;
+}
+
+/// A picker of `source` asked from pane `from`, hung under its tag (UX
+/// DESIGN O1), its field `query`. `rows` are a list's (`source` `list`,
+/// titled `word`).
pub fn open(p: *Pardes, from: usize, source: Source, word: []const u8, query: []const u8, rows: []const u8) void {
const asker = p.panes[from] orelse return;
TagState.toRest(p);
@@ -229,8 +258,8 @@ pub fn open(p: *Pardes, from: usize, source: Source, word: []const u8, query: []
// Find and Grep from the work tree's root (W8), as other finders search.
pk.dir.set(if (source == .find or source == .grep) workTree(p, Pardes.paneDir(asker)) else Pardes.paneDir(asker));
pk.rows = p.gpa.dupe(u8, rows) catch |err| return p.reportError(.at(from), "pick", err);
+ pk.cap = p.view().rects[from].h * 2 / 5;
hostIn(p, pk, from) catch |err| return p.reportError(.at(from), "pick", err);
- if (p.paneBySerial(pk.landing)) |host| pk.cap = p.view().rects[host].h * 2 / 5;
unroll(p, pk, query);
start(p, pk);
filter(p, pk);
@@ -341,30 +370,28 @@ fn nkept(p: *const Pardes) usize {
return n;
}
-/// Picker `pk` asked from pane `from`: the pane it lands in is `from` when
-/// it reads; its reader when it is held and has one; else an untouched
-/// pane, `from` itself first (UX J1), which previews as a reading pane does
-/// and is given back as it was on Esc; else a pane made where its reader
-/// would go, empty until the preview fills it. The keyboard stays where it
-/// was: the landing pane is the tag's host.
+/// Picker `pk` asked from pane `from`, which keeps the keyboard and hangs
+/// its head and band under its tag (UX DESIGN O1). The pane it lands in,
+/// whose body previews: `from` when it reads; its reader when it is held
+/// and has one; else an untouched pane, `from` itself first (UX J1), which
+/// previews as a reading pane does and is given back as it was on Esc;
+/// else a pane made where its reader would go, empty until the preview
+/// fills it. A source with nothing to preview makes no pane and sets
+/// nothing aside: Panes (a row is a pane on the screen), Themes (the whole
+/// window wears the row) and code actions (their edit in the asking text).
fn hostIn(p: *Pardes, pk: *Pick, from: usize) !void {
+ defer p.view().active = from;
const asker = p.panes[from].?;
pk.owner = asker.serial;
+ pk.landing = asker.serial;
pk.made = false;
- // A theme is no place: its list is the asking pane's own tag (§3.5),
- // and its preview the whole window; an action's is that text's edit.
- if (pk.source == .themes or pk.source == .actions) {
- pk.landing = asker.serial;
- p.view().active = from;
- return;
- }
+ if (pk.source == .panes or pk.source == .themes or pk.source == .actions) return;
var reader = if (Trail.reading(p, asker)) from else Trail.readerOf(p, asker);
if (reader == null) if (layout.freeSpace(p, from, .reader)) |free| if (free == .pane) {
reader = free.pane;
};
pk.landing = p.panes[reader orelse try landingFor(p, from)].?.serial;
pk.made = reader == null;
- p.view().active = from;
}
/// A pane made for a picker where pane `from`'s reader goes: under it, or
@@ -380,17 +407,18 @@ fn landingFor(p: *Pardes, from: usize) !usize {
return free;
}
-/// Picker `pk` live in the live view's tag: its host its landing pane, its
-/// field `query`, the cursor where it was.
+/// Picker `pk` live in the live view's tag: hung under its asking pane's
+/// tag (UX DESIGN O1), its field `query`, the cursor where it was.
fn unroll(p: *Pardes, pk: *Pick, query: []const u8) void {
const v = p.view();
const s = &v.tag_state;
s.kind = .pick;
s.pick = pk.id;
- s.host = pk.landing;
+ s.host = pk.owner;
s.field.set(query);
s.rows = .{ .at = @intCast(@min(pk.at, std.math.maxInt(u16))) };
pk.unrolled = true;
+ pk.tall = 0;
pk.shown = no_row;
pk.previewed = false;
// The whole window previews a theme.
@@ -572,6 +600,7 @@ fn toBest(p: *Pardes, pk: *Pick) void {
/// current row.
pub fn produceAll(p: *Pardes, tick: bool) void {
for (p.picks) |slot| if (slot) |pk| if (pk.unrolled) {
+ pk.tall = @intCast(@max(pk.tall, @min(have(p, pk), Band.Cursor.shown)));
if (pk.names.busy()) {
// A cursor on the best match follows it while the rest are
// scored.
@@ -585,6 +614,12 @@ pub fn produceAll(p: *Pardes, tick: bool) void {
};
}
+/// The rows a picker's source has: every name it scores (not what the
+/// query keeps), a Grep's lines and All's places for this query.
+fn have(p: *const Pardes, pk: *const Pick) usize {
+ return if (fuzzy(pk)) pk.names.cands.items.len else count(p, pk);
+}
+
/// The frames a live picker still owes: scoring, a preview (nextWake's).
pub fn busy(p: *const Pardes) bool {
for (p.picks) |slot| if (slot) |pk| if (pk.unrolled) {
@@ -790,9 +825,11 @@ fn rowAt(p: *Pardes, pk: *const Pick, arena: std.mem.Allocator, i: usize) std.me
// ---- the tag ----
-/// The head of the landing pane's tag (SPEC §5.3): the key cells, the
-/// source's word, the query, the count `cursor/total` and `•marked`; on a
-/// second row the other sources' words, under spines from the key cells.
+/// The head under the asking pane's tag (SPEC §5.3, UX DESIGN M2, O1): the
+/// key cells, the source's word, the query, the count `cursor/total` and
+/// `•marked`, and one hint, `M-l acts`, the key to the acts (UX DESIGN O4:
+/// no row of acts and sources; each source has its own key, M-h switches
+/// keeping the query).
pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?TagState.Head {
const pk = live(p) orelse return null;
const s = &p.view().tag_state;
@@ -815,65 +852,29 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !?TagState.Head {
if (n == 0) try text.append(arena, '0') else try text.print(arena, "{d}/{d}", .{ s.rows.at + 1, n });
if (pk.marks.items.len > 0) try text.print(arena, " •{d}", .{pk.marks.items.len});
if (pk.names.busy() or p.stream.busyFor(pk.id)) try text.appendSlice(arena, " ⋯");
- // Themes, actions and Lists have no acts and no other sources: no
- // second row.
- if (pk.source == .themes or pk.source == .actions or pk.source == .lists) {
- const hints = text.items.len;
- try b.styled(switch (pk.source) {
- .themes => "⏎ wear it · esc",
- .lists => "⏎ reopen it · esc",
- else => "⏎ or 1-9 apply it · esc",
- }, .dim);
- try b.right(counted, hints);
- var h = b.done();
- h.caret = caret;
- return h;
- }
- try b.right(counted, text.items.len);
- // The second row, one row (UX D2): under the spines from the key
- // cells, from two cells right of the last, the acts, `|`, the other
- // sources' words, each switching to it, the `|` and the sources dim
- // (UX D4); what does not fit is dropped from the right (the sources
- // first) and the row ends in a dim `…` (M-l and M-h reach them all).
- try b.row(if (b.ncols > 0) b.cols[b.ncols - 1] + 2 else 0);
- var offer: [acts.len + 1 + std.enums.values(Source).len][]const u8 = undefined;
- var nw: usize = 0;
- for (acts) |act| if (offered(pk, act)) {
- offer[nw] = act.word;
- nw += 1;
- };
- const nacts = nw;
- offer[nw] = "|";
- nw += 1;
- inline for (comptime std.enums.values(Source)) |src| if (src != .list and src != .messages and src != .themes and src != .actions and src != .lists and src != pk.source) {
- offer[nw] = words.get(src).word;
- nw += 1;
- };
- for (offer[0..nw], 0..) |word, i| {
- const gap: usize = @intFromBool(i > 0);
- const rest: usize = if (i + 1 < nw) 2 else 0;
- if (b.col() + gap + File.displayWidth(p.settings.tab, word) + rest > b.width) {
- try b.put(if (gap > 0) " " else "");
- try b.styled("…", .dim);
- break;
- }
- try b.put(if (gap > 0) " " else "");
- if (i >= nacts) try b.styled(word, .dim) else try b.put(word);
- }
+ // Themes, code actions and Lists have no acts: no hint.
+ const hints = text.items.len;
+ if (pk.source != .themes and pk.source != .actions and pk.source != .lists) try b.styled("M-l acts", .dim);
+ try b.right(counted, hints);
var h = b.done();
h.caret = caret;
return h;
}
-/// The band's rows (UX D6): as many as the list will show, from what the
-/// source has (not what the query keeps: typing never moves the body),
-/// four at least, eleven at most, and its `cap` at most (the host pane's
-/// 40 % at open: the layout asks this while it lays the column out, when
-/// no pane has its rows yet).
+/// The band's rows (UX D6, DESIGN O4): as many as the list will show, from
+/// what the source has (not what the query keeps: typing never moves the
+/// body) and the most it has had (`tall`): a list known at open exactly its
+/// rows, one whose rows come later (Find, Grep, All, Symbols) three at
+/// least, growing as they come; eleven at most, and its `cap` at most (the
+/// asking pane's 40 % at open: the layout asks this while it lays the
+/// column out, when no pane has its rows yet).
pub fn bandRows(p: *const Pardes) u16 {
const pk = live(p) orelse return 0;
- const have = if (!fuzzy(pk)) Band.Cursor.shown else pk.names.cands.items.len;
- const rows: usize = @max(1, @min(Band.Cursor.shown, @max(4, have), pk.cap));
+ const later: usize = switch (pk.source) {
+ .find, .grep, .all, .symbols => 3,
+ else => 1,
+ };
+ const rows: usize = @max(1, @min(Band.Cursor.shown, @max(later, pk.tall, have(p, pk)), pk.cap));
// Its second step's rows too: the sources, the acts and what they act on.
return @intCast(switch (pk.spine) {
.sources => @max(rows, spine_rows.len),
@@ -982,7 +983,7 @@ pub fn landingLine(p: *Pardes, arena: std.mem.Allocator, pane: *const Pane) ?usi
/// previewing.
pub fn sentence(p: *const Pardes, w: *std.Io.Writer) ?[2]usize {
const pk = live(p) orelse return null;
- if (!pk.previews or pk.source == .themes or pk.source == .actions or pk.source == .lists) return null;
+ if (!pk.previews or pk.source == .themes or pk.source == .actions or pk.source == .lists or pk.source == .panes) return null;
if (pk.landing == pk.owner) {
w.writeAll("⏎ lands here") catch return null;
} else {
@@ -1512,9 +1513,18 @@ fn switchTo(p: *Pardes, pk: *Pick, source: ?Source) void {
for (pk.refined[0..pk.nrefined]) |*r| r.names.deinit(p.gpa);
pk.nrefined = 0;
pk.marks.clearRetainingCapacity();
+ const from_panes = pk.source == .panes;
pk.source = to;
pk.word.set(words.get(to).word);
pk.keys.set(words.get(to).keys);
+ // From Panes, which previews in no pane (hostIn), to a source that
+ // does: its preview where it would have been had it opened as this one.
+ if (from_panes and to != .panes) {
+ var query: Kind.Buf(256) = .{};
+ query.set(s.field.text());
+ hostIn(p, pk, p.paneBySerial(pk.owner) orelse p.view().active) catch |err| return p.reportError(.at(p.view().active), "pick", err);
+ unroll(p, pk, query.slice());
+ }
start(p, pk);
filter(p, pk);
}
@@ -1843,16 +1853,19 @@ pub fn walkList(p: *Pardes, id: usize, forward: bool) bool {
}
/// Look on a list word in pane `id`'s trail (SPEC §6.3), or a walk onto
-/// it at step `walking` (UX L'1): the list unrolled again in that pane's
-/// tag, its rows, marks, cursor and query as they were.
+/// it at step `walking` (UX L'1): the list unrolled again under that
+/// reading pane's tag, which asks it now and previews it, its rows, marks,
+/// cursor and query as they were.
pub fn reopen(p: *Pardes, id: usize, index: u32, walking: ?u8) void {
const pk = byId(p, index) orelse return p.setMessage(.at(id), "walk: that list is gone: the last 8 are kept");
const pane = p.panes[id] orelse return;
TagState.toRest(p);
p.resume_at = 0;
touch(p, pk);
+ pk.owner = pane.serial;
pk.landing = pane.serial;
pk.made = false;
+ p.view().active = id;
unroll(p, pk, pk.query.slice());
unrollRows(p, pk);
pk.walking = walking;
@@ -1906,13 +1919,69 @@ pub fn keyAtRest(p: *Pardes, k: Key) void {
p.resume_at = 0;
}
-/// B3 on a picker's row (mouse.zig bandPress): Enter on it.
+/// Enter on the live picker's current row: B3 on its text where it
+/// previews (mouse.zig, UX DESIGN O3).
pub fn landHere(p: *Pardes) void {
const pk = live(p) orelse return;
if (pk.source == .lists) return reopenListed(p, pk);
if (pk.spine == .rows) land(p, .walk);
}
+/// A press on row `row` of the live picker's band (mouse.zig bandPress, UX
+/// DESIGN O2): B1 (`enter` false) puts the cursor on it, the list's or the
+/// act step's; B3 does what Enter does there (`below`: Shift-B3, as
+/// S-Enter): the row landed, the act applied, the source switched to, the
+/// theme worn, the action applied. A row of the act step or the source
+/// spine is its key's, its first byte (actStep, steps).
+pub fn press(p: *Pardes, row: Band.Row, enter: bool, below: bool) void {
+ const pk = live(p) orelse return;
+ const s = &p.view().tag_state;
+ if ((pk.spine == .acts or pk.spine == .sources) and row.key > 0) {
+ if (enter) return key(p, .{ .cp = row.text[0] });
+ if (pk.spine == .acts) pk.act_at = @intCast(row.index);
+ return;
+ }
+ if (pk.spine != .rows or row.index >= count(p, pk)) return;
+ s.rows.at = row.index;
+ if (!enter) return;
+ if (pk.source == .lists) return reopenListed(p, pk);
+ if (pk.source == .themes or pk.source == .actions) return key(p, .{ .cp = Key.enter });
+ land(p, if (below) .below else .walk);
+}
+
+/// The wheel over the live picker's head or band (UX DESIGN O2): its
+/// cursor `delta` rows on, the band's eleven following it and the preview
+/// with them, as the keys move it.
+pub fn wheel(p: *Pardes, delta: i32) void {
+ const pk = live(p) orelse return;
+ const s = &p.view().tag_state;
+ const n = @min(count(p, pk), std.math.maxInt(u16));
+ if (n == 0 or pk.spine != .rows) return;
+ s.rows.at = @intCast(std.math.clamp(@as(i64, s.rows.at) + delta, 0, @as(i64, @intCast(n)) - 1));
+ if (fuzzy(pk)) pk.names.reachTo(@as(usize, s.rows.at) + Band.Cursor.shown);
+}
+
+/// Whether screen row `row` of pane `id` is text the live picker previews:
+/// its landing pane's body, a place shown in it (UX DESIGN O3). B2 and B3
+/// there land it first: acting on the file is taking it.
+pub fn previewsAt(p: *const Pardes, id: usize, row: u16) bool {
+ const pk = live(p) orelse return false;
+ const pane = p.panes[id] orelse return false;
+ if (pane.serial != pk.landing or !pk.previewed or pk.source == .themes or pk.source == .actions) return false;
+ return row >= p.bodyTop(pane, p.view().rects[id]);
+}
+
+/// The live picker, waiting or not, ended as Esc ends it when what is about
+/// to run changes or closes pane `id`, the pane it asks from or previews in
+/// (UX DESIGN O3: Del, Get, Undo, Put, Keep, a walk step there, a Look that
+/// lands there, the pane closed): the preview's own text back, a pane made
+/// for it gone with it. Anything else leaves it up.
+pub fn yieldFor(p: *Pardes, id: usize) void {
+ const pk = live(p) orelse return;
+ const pane = p.panes[id] orelse return;
+ if (pane.serial == pk.owner or pane.serial == pk.landing) TagState.toRest(p);
+}
+
/// Enter in Lists (UX L'3): the kept picker under its cursor unrolled again
/// as it was left, where Lists was asked from, and the newest now.
fn reopenListed(p: *Pardes, pk: *Pick) void {
@@ -2155,6 +2224,12 @@ fn tagOf(p: *Pardes, arena: std.mem.Allocator, id: usize) ![]const u8 {
return pardes.tagline.tagText(p, arena, p.panes[id].?);
}
+/// The head under pane `id`'s tag (UX DESIGN M2); none at rest.
+fn headOf(p: *Pardes, arena: std.mem.Allocator, id: usize) ![]const u8 {
+ const h = try TagState.head(p, arena, p.panes[id].?);
+ return if (h) |made| made.text else "";
+}
+
fn paneCount(p: *const Pardes) usize {
var n: usize = 0;
for (p.panes) |slot| n += @intFromBool(slot != null);
@@ -2169,7 +2244,7 @@ fn settle(p: *Pardes) void {
}
}
-test "a picker from a held pane unrolls in a reader made for it: its rows in the band, the body the current row's file, Esc takes the reader away" {
+test "a picker from a held pane hangs under that pane's tag, which keeps the keyboard; its preview in a reader made for it under it, whose tag is `‹@pN ›`: the body the current row's file, Esc takes the reader away (UX DESIGN O1)" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 140, .rows = 50 });
defer p.deinit();
p.settings.jumps = .walk;
@@ -2191,12 +2266,13 @@ test "a picker from a held pane unrolls in a reader made for it: its rows in the
const npanes = paneCount(p);
open(p, asker, .find, "", "", "");
const pk = live(p).?;
- // A reader made for it, under the asker; its tag is the picker's.
+ // A reader made for it, under the asker, which hangs the picker.
try std.testing.expectEqual(npanes + 1, paneCount(p));
try std.testing.expect(pk.made);
const reader = p.paneBySerial(pk.landing).?;
- try std.testing.expectEqual(@as(?usize, reader), TagState.hostOf(p));
+ try std.testing.expectEqual(@as(?usize, asker), TagState.hostOf(p));
try std.testing.expectEqual(asker, p.view().active);
+ try std.testing.expect(p.view().rects[reader].y > p.view().rects[asker].y);
settle(p);
try std.testing.expectEqual(@as(usize, 2), count(p, pk));
for ("pick") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
@@ -2205,19 +2281,20 @@ test "a picker from a held pane unrolls in a reader made for it: its rows in the
var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
defer frame.deinit();
const a = frame.allocator();
- const tag = try tagOf(p, a, reader);
- // Out of rest no path (UX D1): not the previewed file's, not Keep;
- // the head starts the tag's text.
- const first = tag[0..std.mem.indexOfScalar(u8, tag, '\n').?];
- try std.testing.expect(std.mem.startsWith(u8, first, "␣ f Find pick ") and std.mem.endsWith(u8, first, " 1/1"));
- try std.testing.expect(std.mem.indexOf(u8, tag, "│ Walk Look Split Newcol Grep Edit Copy Keep Drop | Grep Recent Panes Symbols All Jumplist") != null);
+ // Its tag the owner's word alone (UX DESIGN M3, O1); the head under
+ // the asker's.
+ try std.testing.expect(std.mem.startsWith(u8, try tagOf(p, a, reader), "‹@p"));
+ try std.testing.expectEqualStrings("", try headOf(p, a, reader));
+ const tag = try headOf(p, a, asker);
+ try std.testing.expect(std.mem.startsWith(u8, tag, "␣ f Find pick ") and std.mem.indexOf(u8, tag, " 1/1") != null);
// The body previews the row's file, after a frame of its own.
p.update(.tick);
try std.testing.expectEqualStrings(b_path, p.panes[reader].?.file.?.path);
_ = try p.render(a);
- const r = p.view().rects[reader];
+ const r = p.view().rects[asker];
try std.testing.expectEqualStrings("^", p.surface.at(r.x, r.y).grapheme());
- try std.testing.expect(Band.covered(p, p.panes[reader].?, reader).band >= 1);
+ try std.testing.expect(Band.covered(p, p.panes[asker].?, asker).band >= 1);
+ try std.testing.expectEqual(@as(u16, 0), Band.covered(p, p.panes[reader].?, reader).over);
// Esc: the reader made for it goes, the asker as it was.
p.update(.{ .key = .{ .cp = Key.escape } });
try std.testing.expectEqual(npanes, paneCount(p));
@@ -2226,7 +2303,7 @@ test "a picker from a held pane unrolls in a reader made for it: its rows in the
try std.testing.expectEqualStrings("pick", pk.query.slice());
}
-test "a picker's act row is one row under the spines, two cells right of the last: what does not fit dropped from the right, the sources first, a dim `…` ending it" {
+test "a picker's head is one row: the count and one dim hint at its right end, `M-l acts`; no row of acts and sources, the list's rows right under it; Themes hints nothing (UX DESIGN O4)" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 60, .rows = 40 });
defer p.deinit();
p.settings.jumps = .walk;
@@ -2237,25 +2314,31 @@ test "a picker's act row is one row under the spines, two cells right of the las
_ = try p.setTestFile("held\n");
const asker = p.view().active;
Trail.keep(p.panes[asker].?);
+ p.gpa.free(p.panes[asker].?.file.?.path);
+ p.panes[asker].?.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ std.Io.Dir.path.dirname(a_path).?, "held.txt" });
p.stream.engine = .walk;
open(p, asker, .find, "", "", "");
- const reader = p.paneBySerial(live(p).?.landing).?;
+ settle(p);
var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
defer frame.deinit();
const a = frame.allocator();
- const tag = try tagOf(p, a, reader);
- var rows = std.mem.splitScalar(u8, tag, '\n');
- try std.testing.expect(std.mem.startsWith(u8, rows.next().?, "␣ f Find "));
- const acts_row = rows.next().?;
- try std.testing.expect(rows.next() == null);
- try std.testing.expect(std.mem.startsWith(u8, acts_row, "│ │ Walk Look "));
- try std.testing.expect(std.mem.endsWith(u8, acts_row, " …"));
- try std.testing.expect(File.displayWidth(p.settings.tab, acts_row) <= pardes.tagline.tagWidth(p, reader));
- const h = (try head(p, a, p.panes[reader].?)).?;
+ const tag = try headOf(p, a, asker);
+ try std.testing.expect(std.mem.indexOfScalar(u8, tag, '\n') == null);
+ try std.testing.expect(std.mem.startsWith(u8, tag, "␣ f Find ") and std.mem.endsWith(u8, tag, "1/1 M-l acts"));
+ try std.testing.expectEqual(@as(usize, pardes.tagline.tagWidth(p, asker)), File.displayWidth(p.settings.tab, tag));
+ const h = (try head(p, a, p.panes[asker].?)).?;
try std.testing.expect(h.spans[h.spans.len - 1].style == .dim);
+ // The band's first row the list's first.
+ const band = (try Band.of(p, a, p.panes[asker].?, asker)).?;
+ try std.testing.expect(std.mem.indexOf(u8, (try band.line(a, p.settings.tab, 0)).text, "▶ alpha.zig") != null);
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ open(p, asker, .themes, "", "", "");
+ const themes = try headOf(p, a, asker);
+ try std.testing.expect(std.mem.indexOf(u8, themes, "esc") == null and std.mem.indexOf(u8, themes, "M-l") == null and std.mem.indexOf(u8, themes, "⏎") == null);
+ p.update(.{ .key = .{ .cp = Key.escape } });
}
-test "a picker's band is sized from its list at open, 4 rows at least, and typing never moves it" {
+test "a picker's band is its list's rows (UX DESIGN O4, D6): a list whose rows come later (Find) holds 3 at open, never moved by typing; a list known at open exactly its rows: SPC b b with two panes covers its head and 2 rows" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 });
defer p.deinit();
p.settings.jumps = .walk;
@@ -2272,19 +2355,29 @@ test "a picker's band is sized from its list at open, 4 rows at least, and typin
p.stream.engine = .walk;
open(p, asker, .find, "", "", "");
settle(p);
- const reader = p.paneBySerial(live(p).?.landing).?;
+ const reader = asker;
p.sync();
const rows = Band.covered(p, p.panes[reader].?, reader).band;
- // One or two files listed: four rows, ground under them.
- try std.testing.expectEqual(@as(u16, 4), rows);
+ // One file listed: three rows, ground under it.
+ try std.testing.expectEqual(@as(u16, 3), rows);
for ("zzq") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
settle(p);
p.sync();
try std.testing.expectEqual(@as(usize, 0), count(p, live(p).?));
try std.testing.expectEqual(rows, Band.covered(p, p.panes[reader].?, reader).band);
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ // Two panes: SPC b b's band two rows.
+ p.newScratchBelow(asker);
+ p.view().active = asker;
+ p.sync();
+ for (" bb") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
+ p.sync();
+ try std.testing.expectEqual(Source.panes, live(p).?.source);
+ const at = Band.covered(p, p.panes[asker].?, asker);
+ try std.testing.expect(at.head == 1 and at.band == 2);
}
-test "a picker's band is capped once at open at 40 % of its host pane's rows; the host borrows from its column for a body of 60 % before the band gives way: a Grep from a held pane at 100x30 previews 8 rows at least" {
+test "a picker's band is capped once at open at 40 % of its asking pane's rows; the pane it previews in borrows from its column for a body of 60 %: a Grep from a held pane at 100x30 previews 8 rows at least, in a reader made under it (UX D6, DESIGN O1)" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 });
defer p.deinit();
p.settings.jumps = .walk;
@@ -2302,20 +2395,24 @@ test "a picker's band is capped once at open at 40 % of its host pane's rows; th
p.panes[asker].?.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ std.Io.Dir.path.dirname(a_path).?, "held.txt" });
p.stream.engine = .walk;
p.sync();
+ const at_open = p.view().rects[asker].h;
open(p, asker, .grep, "", "", "");
const reader = p.paneBySerial(live(p).?.landing).?;
- const at_open = p.view().rects[reader].h;
+ try std.testing.expect(reader != asker);
for ("pub fn") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
+ // Its lines after the typing's pause: the band from 3 rows to its cap.
+ if (p.stream.due_ns) |due| p.clock.now_ns = due;
settle(p);
+ try std.testing.expectEqual(@as(usize, 40), count(p, live(p).?));
p.update(.{ .key = .{ .cp = Key.down } });
+ p.update(.tick);
p.sync();
- const pane = p.panes[reader].?;
- const r = p.view().rects[reader];
- const at = Band.covered(p, pane, reader);
+ const at = Band.covered(p, p.panes[asker].?, asker);
try std.testing.expectEqual(@min(Band.Cursor.shown, at_open * 2 / 5), at.band);
- // The rows under the band, the preview's (no row previewed yet: the
- // band over the reader's text, UX DESIGN I1).
- const under = r.h - @max(pane.tag_rows, at.text + at.band);
+ // The preview's rows under the reader's tag, no band over them.
+ const r = p.view().rects[reader];
+ try std.testing.expectEqual(@as(u16, 0), Band.covered(p, p.panes[reader].?, reader).over);
+ const under = r.h - p.panes[reader].?.tag_rows;
try std.testing.expect(under >= 8);
try std.testing.expect(@as(u32, under) * 5 >= @as(u32, r.h) * 3);
}
@@ -2345,8 +2442,8 @@ test "a picker's keys: Tab marks and moves, M-a all and none, C-SPC refines and
try std.testing.expectEqual(@as(u16, 2), s.rows.at);
var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
defer frame.deinit();
- const refs = try tagOf(p, frame.allocator(), id);
- try std.testing.expect(std.mem.indexOf(u8, refs, " Refs ") != null and std.mem.indexOf(u8, refs, " 3/4 •1\n") != null);
+ const refs = try headOf(p, frame.allocator(), id);
+ try std.testing.expect(std.mem.indexOf(u8, refs, " Refs ") != null and std.mem.endsWith(u8, refs, " 3/4 •1 M-l acts"));
p.update(.{ .key = .{ .cp = 'a', .alt = true } });
try std.testing.expectEqual(@as(usize, 4), pk.marks.items.len);
p.update(.{ .key = .{ .cp = 'a', .alt = true } });
@@ -2364,8 +2461,8 @@ test "a picker's keys: Tab marks and moves, M-a all and none, C-SPC refines and
settle(p);
try std.testing.expectEqual(@as(usize, 1), count(p, pk));
_ = frame.reset(.retain_capacity);
- const refined = try tagOf(p, frame.allocator(), id);
- try std.testing.expect(std.mem.indexOf(u8, refined, " Refs alpha | w ") != null and std.mem.indexOf(u8, refined, " 1/1\n") != null);
+ const refined = try headOf(p, frame.allocator(), id);
+ try std.testing.expect(std.mem.indexOf(u8, refined, " Refs alpha | w ") != null and std.mem.endsWith(u8, refined, " 1/1 M-l acts"));
// Backspace twice: the `w` goes, then the refinement, its query back.
p.update(.{ .key = .{ .cp = Key.backspace } });
p.update(.{ .key = .{ .cp = Key.backspace } });
@@ -3178,8 +3275,8 @@ test "a picker's preview starts under its band: its landing line ⌈visible/3⌉
try std.testing.expect(previewing(p, id));
try std.testing.expectEqualStrings(path, pane.file.?.path);
const at = Band.covered(p, pane, id);
- try std.testing.expectEqual(@as(u16, 0), at.over);
- try std.testing.expectEqual(p.tagTop(pane, r) + at.text + at.band, p.bodyTop(pane, r));
+ try std.testing.expectEqual(@as(u16, 0), pane.view.covered);
+ try std.testing.expectEqual(p.tagTop(pane, r) + at.tag + at.over, p.bodyTop(pane, r));
try std.testing.expectEqual(@as(usize, 59 - (pane.rows + 2) / 3), pane.file.?.scroll);
// Line 1: on the row right under the band.
p.update(.{ .key = .{ .cp = Key.down } });
@@ -3698,3 +3795,156 @@ test "Find and Grep search the work tree (W8): from a pane deep in a repo Find l
try std.testing.expectEqualStrings("/", live(p).?.dir.slice());
p.update(.{ .key = .{ .cp = Key.escape } });
}
+
+test "a pane made for a picker has no rest: its tag is its owner's word alone, `‹@pN ›`, its body under it; the head hangs under the asking pane's tag (UX DESIGN M3, O1)" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 140, .rows = 50 });
+ defer p.deinit();
+ p.settings.jumps = .walk;
+ p.stream.engine = .walk;
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ const a_path = try testFile(p, &tmp, "alpha.zig", "const alpha = 1;\n");
+ defer p.gpa.free(a_path);
+ _ = try p.setTestFile("held\n");
+ const asker = p.view().active;
+ Trail.keep(p.panes[asker].?);
+ p.gpa.free(p.panes[asker].?.file.?.path);
+ p.panes[asker].?.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ std.Io.Dir.path.dirname(a_path).?, "held.txt" });
+ const npanes = paneCount(p);
+ open(p, asker, .find, "", "", "");
+ const pk = live(p).?;
+ try std.testing.expect(pk.made);
+ const reader = p.paneBySerial(pk.landing).?;
+ settle(p);
+ p.update(.tick);
+ try std.testing.expectEqualStrings(a_path, p.panes[reader].?.file.?.path);
+ var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer frame.deinit();
+ const a = frame.allocator();
+ const owner = try std.fmt.allocPrint(a, "‹@p{d} › ", .{p.panes[asker].?.serial});
+ try std.testing.expectEqualStrings(owner, try tagOf(p, a, reader));
+ const s = try p.render(a);
+ const r = p.view().rects[reader];
+ var row: std.ArrayList(u8) = .empty;
+ const ra = p.view().rects[asker];
+ for ([_]struct { y: u16, starts: []const u8 }{
+ // The tag's row, the owner's word; the body's under it.
+ .{ .y = r.y, .starts = std.mem.trimEnd(u8, owner, " ") },
+ .{ .y = r.y + 1, .starts = "1▸const alpha" },
+ // The head under the asker's tag.
+ .{ .y = ra.y + p.panes[asker].?.tag_rows, .starts = "␣ f Find " },
+ }) |want| {
+ row.clearRetainingCapacity();
+ for (s.cells[@as(usize, want.y) * s.cols + r.x + pardes.TAG_TEXT_INSET ..][0 .. r.w - pardes.TAG_TEXT_INSET]) |cell| try row.appendSlice(a, cell.grapheme());
+ try std.testing.expect(std.mem.startsWith(u8, std.mem.trimStart(u8, row.items, " "), want.starts));
+ }
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expectEqual(npanes, paneCount(p));
+}
+
+test "SPC b b from a held pane hangs under that pane's own tag (UX DESIGN O1): no pane made, nothing set aside, the keyboard in its field; a Panes list never names a picker's preview" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 140, .rows = 50 });
+ defer p.deinit();
+ p.settings.jumps = .walk;
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ const b_path = try testFile(p, &tmp, "beta.zig", "one\ntwo\nthree\n");
+ defer p.gpa.free(b_path);
+ _ = try p.setTestFile("held\n");
+ const held = p.view().active;
+ Trail.keep(p.panes[held].?);
+ exec.runBuiltin(p, .New, held, "New", null);
+ p.view().active = held;
+ p.sync();
+ var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer frame.deinit();
+ const a = frame.allocator();
+ const rest = try a.dupe(u8, try tagOf(p, a, held));
+ const npanes = paneCount(p);
+ for (" bb") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
+ const pk = live(p).?;
+ try std.testing.expectEqual(Source.panes, pk.source);
+ try std.testing.expectEqual(npanes, paneCount(p));
+ try std.testing.expect(!pk.made);
+ try std.testing.expectEqual(p.panes[held].?.serial, pk.landing);
+ try std.testing.expectEqual(@as(?usize, held), TagState.hostOf(p));
+ try std.testing.expectEqual(held, p.view().active);
+ try std.testing.expectEqualStrings(rest, try tagOf(p, a, held));
+ try std.testing.expect(std.mem.startsWith(u8, try headOf(p, a, held), "␣ b Panes "));
+ settle(p);
+ p.update(.tick);
+ // Nothing previewed, nothing said of a preview: the held pane's own text.
+ try std.testing.expect(pk.aside == null and p.panes[held].?.file.?.output == null);
+ var said: [256]u8 = undefined;
+ var w: std.Io.Writer = .fixed(&said);
+ try std.testing.expect(sentence(p, &w) == null);
+ try std.testing.expectEqual(@as(usize, 2), count(p, pk));
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expectEqual(npanes, paneCount(p));
+ // A list from the held pane previews in the untouched +New (UX J1);
+ // switched to Panes, the +New previewing is not among its rows.
+ const rows = try std.fmt.allocPrint(a, "{s}:3:1 three\n", .{b_path});
+ open(p, held, .list, "Refs", "", rows);
+ settle(p);
+ p.update(.tick);
+ const scratch = p.paneBySerial(live(p).?.landing).?;
+ try std.testing.expect(scratch != held);
+ try std.testing.expectEqualStrings(b_path, p.panes[scratch].?.file.?.path);
+ p.update(.{ .key = .{ .cp = 'h', .alt = true } });
+ p.update(.{ .key = .{ .cp = 'b', .text = "b" } });
+ try std.testing.expectEqual(Source.panes, live(p).?.source);
+ try std.testing.expectEqual(@as(usize, 1), count(p, live(p).?));
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expect(Trail.untouched(p, p.panes[scratch].?));
+}
+
+test "a picker from a held pane with a reader hangs under the held pane's tag and previews in the reader, whose tag names its own file; Esc gives the reader its text back; switched from Panes, it previews where it would have (UX DESIGN O1)" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 140, .rows = 50 });
+ defer p.deinit();
+ p.settings.jumps = .walk;
+ var tmp = std.testing.tmpDir(.{});
+ defer tmp.cleanup();
+ const a_path = try testFile(p, &tmp, "alpha.zig", "const alpha = 1;\n");
+ defer p.gpa.free(a_path);
+ const b_path = try testFile(p, &tmp, "beta.zig", "one\ntwo\nthree\n");
+ defer p.gpa.free(b_path);
+ _ = try p.setTestFile("held\n");
+ const held = p.view().active;
+ Trail.keep(p.panes[held].?);
+ // Its reader: alpha.zig, a Look from it.
+ _ = look.open(p, held, a_path, .{ .line = 1, .col = 1 }, .replace);
+ p.sync();
+ const reader = Trail.readerOf(p, p.panes[held].?).?;
+ try std.testing.expectEqualStrings(a_path, p.panes[reader].?.file.?.path);
+ p.view().active = held;
+ var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer frame.deinit();
+ const a = frame.allocator();
+ const reader_tag = try a.dupe(u8, try tagOf(p, a, reader));
+ const npanes = paneCount(p);
+ const rows = try std.fmt.allocPrint(a, "{s}:3:1 three\n", .{b_path});
+ open(p, held, .list, "Refs", "", rows);
+ settle(p);
+ p.update(.tick);
+ const pk = live(p).?;
+ try std.testing.expectEqual(npanes, paneCount(p));
+ try std.testing.expectEqual(p.panes[reader].?.serial, pk.landing);
+ try std.testing.expectEqual(@as(?usize, held), TagState.hostOf(p));
+ try std.testing.expectEqualStrings(b_path, p.panes[reader].?.file.?.path);
+ try std.testing.expectEqualStrings(reader_tag, try tagOf(p, a, reader));
+ try std.testing.expectEqual(@as(i32, 2), p.panes[reader].?.body.cur_row);
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expectEqualStrings(a_path, p.panes[reader].?.file.?.path);
+ try std.testing.expect(p.panes[reader].?.file.?.output == null);
+ // Panes first, from the held pane: nothing set aside; then M-h r,
+ // Recent, previews in the reader as a list opened there would.
+ open(p, held, .panes, "", "", "");
+ try std.testing.expectEqual(p.panes[held].?.serial, live(p).?.landing);
+ p.update(.{ .key = .{ .cp = 'h', .alt = true } });
+ p.update(.{ .key = .{ .cp = 'r', .text = "r" } });
+ try std.testing.expectEqual(Source.recent, live(p).?.source);
+ try std.testing.expectEqual(p.panes[reader].?.serial, live(p).?.landing);
+ try std.testing.expectEqual(@as(?usize, held), TagState.hostOf(p));
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expectEqualStrings(a_path, p.panes[reader].?.file.?.path);
+}