summaryrefslogtreecommitdiff
path: root/core/Prompt.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/Prompt.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/Prompt.zig')
-rw-r--r--core/Prompt.zig96
1 files changed, 54 insertions, 42 deletions
diff --git a/core/Prompt.zig b/core/Prompt.zig
index 49a9645d..d5f9a374 100644
--- a/core/Prompt.zig
+++ b/core/Prompt.zig
@@ -124,24 +124,28 @@ pub const Ring = struct {
const Info = struct {
/// Its key cell.
cell: []const u8,
- hint: []const u8,
};
const info = std.EnumArray(Op, Info).init(.{
- .search = .{ .cell = "/", .hint = "⏎ land · M-⏎ as a list · C-r history · esc" },
- .search_back = .{ .cell = "?", .hint = "⏎ land · M-⏎ as a list · C-r history · esc" },
- .select = .{ .cell = "s", .hint = "⏎ select · M-⏎ as a list · C-r history · esc" },
- .split = .{ .cell = "S", .hint = "⏎ select · M-⏎ as a list · C-r history · esc" },
- .keep = .{ .cell = "K", .hint = "⏎ keep · M-⏎ as a list · C-r history · esc" },
- .remove = .{ .cell = "A-K", .hint = "⏎ keep · M-⏎ as a list · C-r history · esc" },
- .pipe = .{ .cell = "|", .hint = "⏎ replace · C-r history · esc" },
- .pipe_to = .{ .cell = "A-|", .hint = "⏎ run · C-r history · esc" },
- .insert = .{ .cell = "!", .hint = "⏎ insert · C-r history · esc" },
- .append = .{ .cell = "A-!", .hint = "⏎ append · C-r history · esc" },
- .keep_pipe = .{ .cell = "$", .hint = "⏎ keep · C-r history · esc" },
- .command = .{ .cell = ":", .hint = "Tab complete · ⏎ run · C-r history · esc" },
+ .search = .{ .cell = "/" },
+ .search_back = .{ .cell = "?" },
+ .select = .{ .cell = "s" },
+ .split = .{ .cell = "S" },
+ .keep = .{ .cell = "K" },
+ .remove = .{ .cell = "A-K" },
+ .pipe = .{ .cell = "|" },
+ .pipe_to = .{ .cell = "A-|" },
+ .insert = .{ .cell = "!" },
+ .append = .{ .cell = "A-!" },
+ .keep_pipe = .{ .cell = "$" },
+ .command = .{ .cell = ":" },
});
+/// Every prompt's one hint (UX DESIGN O4): the key to what its head and
+/// band do not show. Enter's verb is the head's own `= Look /dirty/`;
+/// M-Enter and Tab are in Help; Esc is never hinted.
+const hint = "C-r history";
+
/// The history `op` reads and Enter adds to.
fn ring(p: *Pardes, op: Op) *Ring {
return switch (op) {
@@ -846,7 +850,6 @@ pub fn execWord(p: *Pardes, id: usize) void {
/// The span of pane `pane`'s tag its search word takes while its places no
/// longer light it (the first Esc cleared them): drawn dimmed (draw.zig).
pub fn unlit(p: *const Pardes, pane: *Pane) ?[2]usize {
- if (Trail.outOfRest(p, pane)) return null;
const t = &pane.trail;
const whole = pardes.tagline.folded(p, pane).whole;
for (t.steps[0..t.backs()], 0..) |*step, i| if (step.* == .search) {
@@ -1098,7 +1101,7 @@ fn strike(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, line: i32, lo_:
}
/// The head of the prompt's tag: `s self▌ = Exec Edit x/self/ 4
-/// selections in 6 lines ⏎ select · M-⏎ as a list · C-r history · esc`.
+/// selections in 6 lines C-r history`.
pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !TagState.Head {
const s = &p.view().tag_state;
const pr = &s.prompt;
@@ -1140,7 +1143,6 @@ pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !TagState.Head {
}
if (pr.op == .command) try Command.count(p, arena, text);
const hints = text.items.len;
- const hint = info.get(pr.op).hint;
if (tail) |t| {
// Both beside the count, or neither: as much room as the right
// block asks for its two gaps (Builder.right drops the hints alone).
@@ -1369,6 +1371,12 @@ fn tagOf(p: *Pardes) ![]const u8 {
return tagline.tagText(p, p.scratch.allocator(), p.panes[p.view().active].?);
}
+/// The head under the active pane's tag (UX DESIGN M2); none at rest.
+fn headOf(p: *Pardes) ![]const u8 {
+ const h = try TagState.head(p, p.scratch.allocator(), p.panes[p.view().active].?);
+ return if (h) |made| made.text else "";
+}
+
/// Whether `needle` is in `hay`, a run of two spaces or more in either read
/// as two: a right block's padding is its row's (UX D3).
fn has(hay: []const u8, needle: []const u8) bool {
@@ -1397,21 +1405,22 @@ test "s asks in the tag's head: its key cell, the field, the plain word and the
try std.testing.expectEqual(TagState.Kind.prompt, p.view().tag_state.kind);
// No chip on the notice band: the prompt is the tag's.
try std.testing.expectEqual(Pane.Prompt.none, pane.prompt);
- try std.testing.expect(has(try tagOf(p), "s ⏎ select · M-⏎ as a list · C-r history · esc"));
+ // Its one hint at the row's end (UX DESIGN O4).
+ try std.testing.expect(std.mem.startsWith(u8, try headOf(p), "s ") and std.mem.endsWith(u8, try headOf(p), " C-r history"));
typeKeys(p, "self");
- try std.testing.expect(has(try tagOf(p), "s self = Exec Edit x/self/ 2 selections in 3 lines ⏎ select"));
+ try std.testing.expect(has(try headOf(p), "s self = Exec Edit x/self/ ") and has(try headOf(p), "2 selections in 3 lines C-r history"));
try std.testing.expectEqual(@as(u16, 1), pane.body.nsel);
try std.testing.expect(selecting(p, pane).?.dim == false);
// No match: 0, and the selection it began with.
typeKeys(p, "x");
- try std.testing.expect(has(try tagOf(p), "= Exec Edit x/selfx/ 0 "));
+ try std.testing.expect(has(try headOf(p), "= Exec Edit x/selfx/ 0 "));
try std.testing.expectEqual(@as(u16, 0), pane.body.nsel);
p.update(.{ .key = .{ .cp = Key.backspace } });
try std.testing.expectEqual(@as(u16, 1), pane.body.nsel);
// No regex: the two from before, dimmed, and why.
typeKeys(p, "(");
// Its reason in place of the hints (UX D14), what follows it dim.
- try std.testing.expect(std.mem.endsWith(u8, try tagOf(p), " bad regular expression · the 2 from before shown, dimmed"));
+ try std.testing.expect(std.mem.endsWith(u8, try headOf(p), " bad regular expression · the 2 from before shown, dimmed"));
try std.testing.expectEqual(@as(u16, 1), pane.body.nsel);
try std.testing.expect(selecting(p, pane).?.dim);
// Esc: rest, the tag and the selection as they were.
@@ -1439,10 +1448,10 @@ test "Enter keeps what s found, the pattern in / and in the history Up brings ba
typeKeys(p, "K");
p.update(.{ .key = .{ .cp = Key.up } });
try std.testing.expectEqualStrings("self..", p.view().tag_state.field.text());
- try std.testing.expect(has(try tagOf(p), "K self.. = Exec Edit g/self../ keeps 2 of 2"));
+ try std.testing.expect(has(try headOf(p), "K self.. = Exec Edit g/self../ keeps 2 of 2"));
p.update(.{ .key = .{ .cp = Key.down } });
typeKeys(p, "b");
- try std.testing.expect(has(try tagOf(p), "K b = Exec Edit g/b/ keeps 1 of 2 ⏎ keep"));
+ try std.testing.expect(has(try headOf(p), "K b = Exec Edit g/b/ ") and has(try headOf(p), "keeps 1 of 2 C-r history"));
// Ctrl-r: the history under the tag, a row a line.
p.update(.{ .key = .{ .cp = 'r', .ctrl = true } });
try std.testing.expectEqual(@as(u16, 1), Band.takes(p, p.view().active));
@@ -1454,7 +1463,7 @@ test "Enter keeps what s found, the pattern in / and in the history Up brings ba
typeKeys(p, "|");
try std.testing.expectEqual(Pane.Prompt.none, pane.prompt);
p.update(.{ .key = .{ .cp = 't', .text = "tr a-z A-Z" } });
- try std.testing.expect(has(try tagOf(p), "| tr a-z A-Z = Exec Edit |tr a-z A-Z ⋯ ⏎ replace"));
+ try std.testing.expect(has(try headOf(p), "| tr a-z A-Z = Exec Edit |tr a-z A-Z ") and has(try headOf(p), "⋯ C-r history"));
p.update(.{ .key = .{ .cp = Key.enter } });
try std.testing.expectEqualStrings("tr a-z A-Z", p.registers.value('|', 0).?);
var asked: ?u32 = null;
@@ -1491,9 +1500,9 @@ test "/ searches the body as it is typed: the current place selected, `▸` in t
pane.body.cur_row = 2;
pane.body.cur_col = 6;
typeKeys(p, "/dirty");
- try std.testing.expect(has(try tagOf(p), "/ dirty = Look /dirty/ 3/7 · 5 lines ⏎ land · M-⏎ as a list"));
+ try std.testing.expect(has(try headOf(p), "/ dirty = Look /dirty/ ") and has(try headOf(p), "3/7 · 5 lines C-r history"));
try std.testing.expectEqual(@as(?usize, 2), pane.places.current);
- try std.testing.expectEqualStrings(" ", try gutterAt(p, frame.allocator(), 0));
+ // (Its first row under the head's, UX DESIGN M2.)
try std.testing.expectEqualStrings(" ", try gutterAt(p, frame.allocator(), 1));
try std.testing.expectEqualStrings("▸", try gutterAt(p, frame.allocator(), 2));
try std.testing.expectEqualStrings(" ", try gutterAt(p, frame.allocator(), 7));
@@ -1504,8 +1513,9 @@ test "/ searches the body as it is typed: the current place selected, `▸` in t
const x = r.x + config.GUTTER + File.gutterWidth(pane);
const y = p.bodyTop(pane, r);
try std.testing.expectEqual(pardes.Color{ .rgb = c.page.key }, s.at(x - 1 - File.laneCells(pane) - pane.layers.heat, y + 2).style.fg);
- // Line 1's place (`dirty` at its start) on the hit ground.
- try std.testing.expectEqual(pardes.Color{ .rgb = c.hit }, s.at(x, y).style.bg);
+ // Line 5's place (`dirty` at its start) on the hit ground (line 1's
+ // under the head's row, UX DESIGN M2).
+ try std.testing.expectEqual(pardes.Color{ .rgb = c.hit }, s.at(x, y + 4).style.bg);
}
p.update(.{ .key = .{ .cp = Key.enter } });
try std.testing.expectEqual(TagState.Kind.rest, p.view().tag_state.kind);
@@ -1548,13 +1558,13 @@ test "? searches back from the caret; no match is 0; a pattern that is no regex
pane.body.cur_col = 6;
const was = pane.body.primaryRange(pane.file.?.content, 0);
typeKeys(p, "?dirty");
- try std.testing.expect(has(try tagOf(p), "? dirty = Look ?dirty? 2/7 · 5 lines ⏎ land"));
+ try std.testing.expect(has(try headOf(p), "? dirty = Look ?dirty? ") and has(try headOf(p), "2/7 · 5 lines C-r history"));
typeKeys(p, "x");
- try std.testing.expect(has(try tagOf(p), "= Look ?dirtyx? 0 ⏎ land"));
+ try std.testing.expect(has(try headOf(p), "= Look ?dirtyx? ") and has(try headOf(p), "0 C-r history"));
try std.testing.expectEqualDeep(was, pane.body.primaryRange(pane.file.?.content, 0));
p.update(.{ .key = .{ .cp = Key.backspace } });
typeKeys(p, "(");
- try std.testing.expect(has(try tagOf(p), " bad regular expression · "));
+ try std.testing.expect(has(try headOf(p), " bad regular expression · "));
try std.testing.expect(dims(p, pane) and pane.places.started);
try std.testing.expectEqualStrings("dirty", pane.places.pattern);
p.update(.{ .key = .{ .cp = Key.escape } });
@@ -1585,7 +1595,8 @@ test "sam prompts one after another make one recipe word, the Edit line it is; a
try std.testing.expectEqual(@as(usize, 29), @max(back.anchor, back.head));
// A motion ends it: the next s is a recipe of its own, the pane's one.
typeKeys(p, "j%sself..");
- for ([_]u16{ 0, 1, 2 }) |row| try std.testing.expectEqualStrings("┃", try gutterAt(p, frame.allocator(), row));
+ // (Its first row under the head's, UX DESIGN M2.)
+ for ([_]u16{ 1, 2 }) |row| try std.testing.expectEqualStrings("┃", try gutterAt(p, frame.allocator(), row));
p.update(.{ .key = .{ .cp = Key.enter } });
try std.testing.expect(std.mem.startsWith(u8, try tagOf(p), "Edit x/self../ › /test.txt "));
try std.testing.expectEqual(@as(u8, 1), pane.trail.n);
@@ -1636,23 +1647,24 @@ test "a pipe prompt runs a known filter live, a run a selection: the outputs gho
p.update(.{ .key = .{ .cp = Key.enter } });
typeKeys(p, "|");
p.update(.{ .key = .{ .cp = 't', .text = "tr a-z A-Z" } });
- try std.testing.expect(has(try tagOf(p), "| tr a-z A-Z = Exec Edit |tr a-z A-Z ⋯ ⏎ replace"));
+ try std.testing.expect(has(try headOf(p), "| tr a-z A-Z = Exec Edit |tr a-z A-Z ") and has(try headOf(p), "⋯ C-r history"));
const first = lastPipe(p) orelse return error.MissingLiveRun;
const asked = p.pipe.pipeRequest(first).?;
try std.testing.expectEqual(@as(usize, 2), asked.inputs.len);
try std.testing.expect(has(asked.command, "tr a-z A-Z") and has(asked.command, "\\036"));
p.update(.{ .pipe_resp = .{ .id = first, .success = true, .outputs = &.{ "B\x1e\x1e0", "A\x1e\x1e0" } } });
- try std.testing.expect(has(try tagOf(p), " 2 lines → 2 · exit 0 ⏎ replace"));
+ try std.testing.expect(has(try headOf(p), "2 lines → 2 · exit 0 C-r history"));
// The body: each output a ghost line under the line it replaces, the
- // rows below pushed down; the text as it was.
+ // rows below pushed down; the text as it was; its first row under the
+ // head's (UX DESIGN M2).
p.sync();
const s = try p.render(frame.allocator());
const r = p.view().rects[0];
const x = r.x + config.GUTTER + File.gutterWidth(pane);
const y = p.bodyTop(pane, r);
- for ([_][]const u8{ "b", "B", "a", "A", "c" }, 0..) |want, row| try std.testing.expectEqualStrings(want, s.at(x, y + @as(u16, @intCast(row))).grapheme());
+ for ([_][]const u8{ "B", "a", "A", "c" }, 1..) |want, row| try std.testing.expectEqualStrings(want, s.at(x, y + @as(u16, @intCast(row))).grapheme());
// On the chrome's diff rows (R10), the ghost in the page's text.
- try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().del.row }, s.at(x, y).style.bg);
+ try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().del.row }, s.at(x, y + 2).style.bg);
try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().add.row }, s.at(x, y + 1).style.bg);
try std.testing.expectEqual(pardes.Color{ .rgb = p.chrome().page.text }, s.at(x, y + 1).style.fg);
try std.testing.expectEqualStrings("b\na\nc\n", pane.file.?.content);
@@ -1663,16 +1675,16 @@ test "a pipe prompt runs a known filter live, a run a selection: the outputs gho
// No known filter: not run until C-p.
typeKeys(p, "|");
p.update(.{ .key = .{ .cp = 'r', .text = "rot13" } });
- try std.testing.expect(has(try tagOf(p), " rot13 isn't a known filter · C-p runs it"));
+ try std.testing.expect(has(try headOf(p), " rot13 isn't a known filter · C-p runs it"));
try std.testing.expect(lastPipe(p) == null);
p.update(.{ .key = .{ .cp = 'p', .ctrl = true } });
const second = lastPipe(p) orelse return error.MissingLiveRun;
p.update(.{ .pipe_resp = .{ .id = second, .success = true, .outputs = &.{ "\x1eoops: no\x1e2", "X\x1e\x1e0" } } });
- try std.testing.expect(has(try tagOf(p), " 2 runs · 1 ok · 1 exit 2 oops: no "));
+ try std.testing.expect(has(try headOf(p), " 2 runs · 1 ok · 1 exit 2 oops: no "));
// Enter refused once, said; again, the one that worked applied.
p.update(.{ .key = .{ .cp = Key.enter } });
try std.testing.expectEqual(TagState.Kind.prompt, p.view().tag_state.kind);
- try std.testing.expect(has(try tagOf(p), "oops: no — ⏎ again applies the 1 that worked"));
+ try std.testing.expect(has(try headOf(p), "oops: no — ⏎ again applies the 1 that worked"));
p.update(.{ .key = .{ .cp = Key.enter } });
try std.testing.expectEqual(TagState.Kind.rest, p.view().tag_state.kind);
try std.testing.expectEqualStrings("B\nX\nc\n", pane.file.?.content);
@@ -1783,7 +1795,7 @@ test "a search's count keeps ` · N lines` after it in the dim ink, and drops it
const h = try head(p, p.scratch.allocator(), pane);
const lines = std.mem.indexOf(u8, h.text, " \u{b7} 5 lines");
if (cols == 200) {
- try std.testing.expect(has(h.text, "3/7 \u{b7} 5 lines \u{23ce} land"));
+ try std.testing.expect(has(h.text, "3/7 \u{b7} 5 lines C-r history"));
const dim = for (h.spans) |span| {
if (span.lo == lines.? and span.style == .dim) break span;
} else return error.TestUnexpectedResult;
@@ -1791,7 +1803,7 @@ test "a search's count keeps ` · N lines` after it in the dim ink, and drops it
} else {
// No room for the hints: the count alone, at the row's end.
try std.testing.expect(lines == null);
- try std.testing.expect(std.mem.indexOf(u8, h.text, "\u{23ce} land") == null);
+ try std.testing.expect(std.mem.indexOf(u8, h.text, "C-r history") == null);
try std.testing.expect(std.mem.endsWith(u8, h.text, "3/7"));
}
}
@@ -1802,7 +1814,7 @@ test "a search's count keeps ` · N lines` after it in the dim ink, and drops it
pane.body.cur_row = 7;
pane.body.cur_col = 6;
typeKeys(p, "/dirty");
- try std.testing.expect(has(try tagOf(p), "1/7 \u{21bb} \u{b7} 5 lines \u{23ce} land"));
+ try std.testing.expect(has(try headOf(p), "1/7 \u{21bb} \u{b7} 5 lines C-r history"));
}
test "C-r's history has the band's cursor like any list (UX D5): `▶` on its newest line, Down and C-n, Up and C-p move it, Enter takes the line under it" {