diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-24 19:30:38 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-24 19:30:38 -0300 |
| commit | a79de661ee8cf443e88030a9546d06da9fbb4c0b (patch) | |
| tree | 7de4390ee955e5209eb5d4c27b58d0239841a734 | |
| parent | 1c4aea3b0298f6f59ffec9b49f4d5e5f38c8af0f (diff) | |
| download | pardes-a79de661ee8cf443e88030a9546d06da9fbb4c0b.tar.gz pardes-a79de661ee8cf443e88030a9546d06da9fbb4c0b.zip | |
walk (pick-ui SPEC §6.4, item 4 of the Walk UI line B): Ctrl-o goes back one place in a reading pane's walk and Ctrl-i forward one (Trail.walkBy, at the head of Jump.jumpBy, so Back, Forward, the keys and the mouse's side buttons all take it), past its first place (its owner's word is no place) or its last, and from a held pane, the jump list's step as before; the hook for Ctrl-i stepping the Walk queue once the pickers make one is a comment where it goes; TEST FIRST: Trail.zig "Ctrl-o goes back one place in a reader's walk and Ctrl-i forward again; past its first place, or from a held pane, the jump list's"; core-test 999/1165 (166 skipped), pane-test 183/184, behaviour-test 277/277
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| -rw-r--r-- | core/Jump.zig | 4 | ||||
| -rw-r--r-- | core/Trail.zig | 45 |
2 files changed, 49 insertions, 0 deletions
diff --git a/core/Jump.zig b/core/Jump.zig index a83b6ab4..a4ecca04 100644 --- a/core/Jump.zig +++ b/core/Jump.zig @@ -274,6 +274,10 @@ pub fn trackJump(p: *Pardes) void { /// always have, at the newest entry. pub fn jumpBy(p: *Pardes, delta: i32) void { const v = p.view(); + // A reading pane's walk first (pick-ui SPEC §6.4). Past its newest + // step, Ctrl-i is to step the Walk queue once the pickers make one; + // until then, the jump list's. + if (pardes.Trail.walkBy(p, v.active, delta)) return; const older = delta < 0; // At an end of the list: said, not a step that silently does nothing. if (v.jumps.n == 0 or (older and v.jumps.cur == 0) or (!older and v.jumps.cur + 1 >= v.jumps.n)) diff --git a/core/Trail.zig b/core/Trail.zig index a198cae5..3faccafa 100644 --- a/core/Trail.zig +++ b/core/Trail.zig @@ -222,6 +222,23 @@ pub fn edited(p: *Pardes, f: *const panes.File.State) void { } +/// Back (`delta` < 0) or forward one place in reading pane `id`'s walk, +/// as Ctrl-o and Ctrl-i go first (pick-ui SPEC §6.4): true when it had +/// one that way, false to leave the step to the jump list (Jump.jumpBy). +pub fn walkBy(p: *Pardes, id: usize, delta: i32) bool { + const pane = p.panes[id] orelse return false; + if (!reading(p, pane)) return false; + const t = &pane.trail; + var i: usize = t.cur; + while (if (delta < 0) i > 0 else i + 1 < t.n) { + i = if (delta < 0) i - 1 else i + 1; + if (t.steps[i] != .place) continue; + _ = go(p, id, @intCast(i)) catch |err| p.reportError(.at(id), "walk", err); + return true; + } + return false; +} + // ---- the words ---- pub const Part = enum { back, forward }; @@ -586,3 +603,31 @@ test "a trail keeps its newest three back steps whole, older ones fold to ·, an try clickTag(p, r, "·", .right); try std.testing.expectEqualStrings("rank.zig:10", f.at(&at)); } + +test "Ctrl-o goes back one place in a reader's walk and Ctrl-i forward again; past its first place, or from a held pane, the jump list's" { + var f: Fixture = .{ .p = undefined, .tmp = undefined }; + try f.init(60); + defer f.deinit(); + const p = f.p; + var at: [64]u8 = undefined; + f.look(f.held, "rank.zig", 12); + f.look(p.view().active, "place.zig", 8); + f.look(p.view().active, "place.zig", 40); + const back: pardes.Key = .{ .cp = 'o', .ctrl = true }; + const ahead: pardes.Key = .{ .cp = 'i', .ctrl = true }; + p.update(.{ .key = back }); + p.sync(); + try std.testing.expectEqualStrings("place.zig:8", f.at(&at)); + p.update(.{ .key = back }); + p.sync(); + try std.testing.expectEqualStrings("rank.zig:12", f.at(&at)); + p.update(.{ .key = ahead }); + p.sync(); + try std.testing.expectEqualStrings("place.zig:8", f.at(&at)); + p.update(.{ .key = back }); + p.sync(); + try std.testing.expectEqualStrings("rank.zig:12", f.at(&at)); + // The owner's word is no place: past the first, the jump list's. + try std.testing.expect(!walkBy(p, p.view().active, -1)); + try std.testing.expect(!walkBy(p, f.held, -1)); +} |
