summaryrefslogtreecommitdiff
path: root/core/Pick.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-26 00:04:32 -0300
committerGabriel Schneider <[email protected]>2026-11-26 02:11:20 -0300
commit3ace8b385e02a54830decb6aa48d1fa28d076a18 (patch)
tree0134d81f9fee3ca31f8037d0e894388abd30fffe /core/Pick.zig
parent94f00e966c908d370e34ed5e0496a86b33de26d6 (diff)
downloadpardes-3ace8b385e02a54830decb6aa48d1fa28d076a18.tar.gz
pardes-3ace8b385e02a54830decb6aa48d1fa28d076a18.zip
Trail, Pick, Prompt, Jump: Ctrl-o pops the walk one word at a time (UX DESIGN L'1, binding; the user: "I did spc f f then did /something but I didn't know how to get back to the previous one", "the pickers are kinda shown as a stack right? I felt like I could pop the current one"): the trail's words, left to right, are the stack, and Ctrl-o steps one word left of where the pane is, Ctrl-i one right; onto a place as before (Trail.go); onto a list's word, that kept picker unrolls again in this pane's tag as it was left (query, cursor, marks), previewing here (Pick.reopen with `walking`, its step): Esc gives rest exactly as before the Ctrl-o, Enter lands as that word's (a step from it, the steps after it dropped, its word saying where it is now), Ctrl-o, Ctrl-i and Backspace on its empty field (after its refinements) roll it up unlanded and walk on (Pick.walkOn; past the last word the jump list's step alone, Jump.listBy); Ctrl-i in it is Tab, a mark, where the terminal cannot tell them apart; onto a search's word, the caret back where the search started and its places lit (Prompt.light, Look's without the select): `Step.search` is a `Search` that holds its start, path, line and column, recorded as `/` commits (Prompt.word from Places.origin) and by `*`; the pane is then at that word (`cur` on it: Trail.backs writes it before the path, n and N walk it, keep keeps it, a step from it keeps it, go and replaceStep never write a place over it); a held pane walks its own words, a search's and a recipe's; a list no longer kept is said (`walk: that list is gone: the last 8 are kept`) and passed by; the owner is no word to walk; Jumps new-pane walks nothing, as before; D8's fold takes places only: each run of places older than the newest `whole` back steps (or past the first two forward) is one `+N` where it starts, a list's word folds only where the tag keeps its newest step alone and never the newest list's, a search's or a recipe's never (Trail.folds; draw.zig dims every run's `+N`); after a landing (Pick.listed) and a search's Enter (Prompt.land) the notice row says, as an echo never logged, what the next Ctrl-o reaches, `C-o back to Find words 1/1` (Trail.sayBack); THE CAUSE of the user's trouble (UX L1): Trail.walkBy skipped every word but a place (`if (t.steps[i] != .place) continue;`), so Ctrl-o after the search went to main.zig:1, past both the search and the list, and nothing said which key would pop; RUN (TEST FIRST): Jump.zig "Ctrl-o pops the walk one word at a time (UX L'1) ..." (W2's test extended) types the user's keys in an 84x20 session of main.zig (SPC f f words, Enter, /in_word, Enter, then Ctrl-o x3 and Ctrl-i x3) and asks after each key the file, the trail's four steps and where the pane is among them, the caret's line, Find words unrolled or not and the search lit or not, then Esc from a reopened list (as before the Ctrl-o), its Enter (the search's word and the place after it dropped, `Find words 1/1` kept) and Backspace on its empty field (walks on to main.zig): fails on the base at Jump.zig:565 on the first Ctrl-o (expected words.zig, found main.zig), passes now; Trail.zig "the fold takes places alone (UX L'1) ..." (runs of places each a `+N`, a click on each its newest, two lists with the newest step alone, a search's word never) and "a held pane walks its own words (UX L'1) ..." (Ctrl-o puts the caret at 20:3 where `/line 9` began, its places lit; past it the jump list's); the notice-row test of walk UI G 2e now reads the echo, then the caret's place once it is retired; a user hit it on every Ctrl-o after a picker's Enter or a search; goldens re-recorded: find and fsearch (the notice row after a picker's Enter and a search's Enter reads the echo); ttyhelp is the merge's placeholder (M1 re-records it); the perf cell walk-pop (test/perf.zig, run only when named: Ctrl-o onto a list word reopening it in the key's own frame, then Esc), 326 us a pair on small in ReleaseFast; core-test 1124/1298 (173 skipped; the G 2e notice-row test, failing on the echo, updated and passing alone), shell-test 1346/1349 (3 skipped), behaviour-test 280/280, pane-test 183/184, process-test 3 of 147 failed before the two goldens moved (find, fsearch: the echo; ttyhelp the placeholder); load 2.2 to 7.2
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.zig59
1 files changed, 52 insertions, 7 deletions
diff --git a/core/Pick.zig b/core/Pick.zig
index 8669314f..c49e8682 100644
--- a/core/Pick.zig
+++ b/core/Pick.zig
@@ -147,6 +147,10 @@ act_at: u8 = 0,
queue: std.ArrayList(Queued) = .empty,
queue_bytes: std.ArrayList(u8) = .empty,
queue_at: u32 = 0,
+/// The step of its landing pane's trail a walk reopened it at (Ctrl-o,
+/// UX L'1): its Ctrl-o and Ctrl-i walk on from that word, and its Enter
+/// lands as that word's, the steps after it dropped.
+walking: ?u8 = null,
pub const Queued = struct { path: u32, len: u16, line: u32, col: u32 };
@@ -957,6 +961,7 @@ pub fn rollUp(p: *Pardes) void {
pk.spine = .rows;
pk.at = s.rows.at;
pk.unrolled = false;
+ pk.walking = null;
if (p.stream.target == pk.id) _ = p.stream.stop();
restore(p, pk);
}
@@ -1148,6 +1153,10 @@ pub fn key(p: *Pardes, k: Key) void {
_ = s.field.key(k);
return;
}
+ // A list a walk reopened (UX L'1): Ctrl-o and Ctrl-i walk on from its
+ // word, the list rolled up unlanded. Ctrl-i is Tab where the terminal
+ // cannot tell them apart: a mark, as Tab.
+ if (pk.walking) |at| if (ctrl and (k.cp == 'o' or k.cp == 'i')) return walkOn(p, pk, at, if (k.cp == 'o') -1 else 1);
if (alt and (k.cp == Key.enter or k.cp == 'l')) {
pk.spine = .acts;
pk.act_at = 0;
@@ -1308,6 +1317,7 @@ fn back(p: *Pardes, pk: *Pick) void {
if (!fuzzy(pk) and pk.source == .all) filter(p, pk);
return;
}
+ if (pk.walking) |at| return walkOn(p, pk, at, -1);
const keys = pk.keys;
TagState.toRest(p);
if (keys.len == 0) return;
@@ -1318,6 +1328,16 @@ fn back(p: *Pardes, pk: *Pick) void {
s.unrolled = true;
}
+/// Ctrl-o (`delta` < 0) or Ctrl-i in a list a walk reopened at step `at`
+/// of its landing pane's trail (UX L'1): the list rolled up unlanded, the
+/// pane as it was, and the walk on from the list's word; past the last
+/// word, the jump list's step.
+fn walkOn(p: *Pardes, pk: *Pick, at: u8, delta: i32) void {
+ const id = p.paneBySerial(pk.landing) orelse return TagState.toRest(p);
+ TagState.toRest(p);
+ if (!Trail.walkFrom(p, id, at, delta)) pardes.Jump.listBy(p, delta);
+}
+
/// C-q: the rows (the marked, else all, `Query.max_rows` at most) kept as
/// text in a +Search under the asking pane, the source's word and query
/// its first line, each row an address a Look opens.
@@ -1379,6 +1399,7 @@ fn land(p: *Pardes, wanted: How) void {
const a = arena.allocator();
const picked = pickedRows(p, pk, a) catch return;
if (picked.len == 0) return;
+ const walking = pk.walking;
// Walk: the first now, the others queued for C-i.
pk.queue.clearRetainingCapacity();
pk.queue_bytes.clearRetainingCapacity();
@@ -1412,9 +1433,17 @@ fn land(p: *Pardes, wanted: How) void {
_ = p.store.reopen(p, serial, from);
},
.place => |at| if (k == 0 and (how == .walk or how == .queue)) {
+ // A list a walk reopened lands as its word's (UX L'1): a step
+ // from that word, the steps after it dropped.
+ const word: ?u8 = if (walking) |i| (if (from == landing and isWord(p.panes[from].?, i, pk.id)) i else null) else null;
+ if (word) |i| {
+ const trail = &p.panes[from].?.trail;
+ trail.n = i + 1;
+ trail.cur = i;
+ }
switch (look.open(p, from, at.path, at.at, .replace)) {
.none => {},
- else => listed(p, pk),
+ else => listed(p, pk, word),
}
} else if (k == 0 and how == .column) {
// A column made only where there is no free space (UX J1).
@@ -1452,11 +1481,25 @@ fn wordOf(p: *const Pardes, pk: *const Pick, buf: *Kind.Buf(Trail.max_text)) []c
return buf.slice();
}
+/// Whether step `i` of pane `pane`'s trail is picker `id`'s word.
+fn isWord(pane: *const Pane, i: u8, id: u32) bool {
+ const t = &pane.trail;
+ return i < t.n and t.steps[i] == .list and t.steps[i].list.index == id;
+}
+
/// The list rolled into the trail of the reading pane it landed in, its
-/// word before the place: the list `n` and `N` walk there.
-fn listed(p: *Pardes, pk: *const Pick) void {
- const pane = p.panes[p.view().active] orelse return;
+/// word before the place: the list `n` and `N` walk there; a list a walk
+/// reopened at step `at` says where it is now in that word. The notice row
+/// says what Ctrl-o goes back to (UX L'1).
+fn listed(p: *Pardes, pk: *const Pick, at: ?u8) void {
+ const id = p.view().active;
+ const pane = p.panes[id] orelse return;
if (!Trail.reading(p, pane)) return;
+ defer Trail.sayBack(p, id);
+ if (at) |i| if (isWord(pane, i, pk.id)) {
+ _ = wordOf(p, pk, &pane.trail.steps[i].list.text);
+ return;
+ };
var w: Trail.Word = .{ .index = pk.id };
_ = wordOf(p, pk, &w.text);
Trail.through(&pane.trail, .{ .list = w });
@@ -1502,9 +1545,10 @@ pub fn walkList(p: *Pardes, id: usize, forward: bool) bool {
return true;
}
-/// Look on a list word in pane `id`'s trail (SPEC §6.3): the list unrolled
-/// again in that pane's tag, its rows, marks, cursor and query as they were.
-pub fn reopen(p: *Pardes, id: usize, index: u32) void {
+/// 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.
+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);
@@ -1512,6 +1556,7 @@ pub fn reopen(p: *Pardes, id: usize, index: u32) void {
pk.made = false;
unroll(p, pk, pk.query.slice());
unrollRows(p, pk);
+ pk.walking = walking;
}
/// A list unrolled again: All's places found again, the cursor where it was.