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/Prompt.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/Prompt.zig')
| -rw-r--r-- | core/Prompt.zig | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/core/Prompt.zig b/core/Prompt.zig index 49a9645d..e9c231da 100644 --- a/core/Prompt.zig +++ b/core/Prompt.zig @@ -846,7 +846,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) { @@ -1369,6 +1368,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 +1402,21 @@ 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")); + try std.testing.expect(has(try headOf(p), "s ⏎ select · M-⏎ as a list · C-r history · esc")); 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/ 2 selections in 3 lines ⏎ select")); 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 +1444,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/ keeps 1 of 2 ⏎ keep")); // 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 +1459,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 ⋯ ⏎ replace")); 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 +1496,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/ 3/7 · 5 lines ⏎ land · M-⏎ as a list")); 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 +1509,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 +1554,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? 2/7 · 5 lines ⏎ land")); 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? 0 ⏎ land")); 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 +1591,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 +1643,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 ⋯ ⏎ replace")); 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 ⏎ replace")); // 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 +1671,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); @@ -1802,7 +1810,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 \u{23ce} land")); } 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" { |
