diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 17:52:24 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 18:02:10 -0300 |
| commit | afec162464d360cbbf475d3fb7457cda83ce918f (patch) | |
| tree | 7278bc32743769c096fd743758ea3a2967b8be93 /src/ninep/ctl.zig | |
| parent | fe9ec319e01052e3ede65ad0e8a809dd5f2c9953 (diff) | |
| download | pardes-afec162464d360cbbf475d3fb7457cda83ce918f.tar.gz pardes-afec162464d360cbbf475d3fb7457cda83ce918f.zip | |
Back and Forward keep to the focused file: Ctrl-o, Ctrl-i, the mouse's side buttons (now the tty's 8 and 9 too), the builtins and 9P go to the nearest place that way in this pane, else in this file in another pane, else of any file; JumpScope all takes every place in order as before
Diffstat (limited to 'src/ninep/ctl.zig')
| -rw-r--r-- | src/ninep/ctl.zig | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 157bc8b9..0f4e181c 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -3576,6 +3576,53 @@ test "Back and Forward over a closed file's entries: one reopen is that file's p try testing.expectEqual(c_serial, p.panes[p.active].?.serial); } +test "Back and Forward written to exec keep to the focused file, and JumpScope all, written to ctl, takes every place in order" { + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "a.txt", .data = "row\n" ** 100 }); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "b.txt", .data = "row\n" ** 100 }); + var dir_buf: [4096]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)]; + var line: [4200]u8 = undefined; + // Each a look, as a user's jumps are: b1 a1 b40 a40 b80 a80. + for ([_][]const u8{ "b.txt:1", "a.txt:1", "b.txt:40", "a.txt:40", "b.txt:80", "a.txt:80" }) |place| { + try testing.expectEqual(Status.ok, wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/{s}\n", .{ dir, place })).reply.status); + p.sync(); + } + const Step = struct { word: []const u8, file: []const u8, line: i32 }; + const walk = struct { + fn run(q: *Pardes, steps: []const Step) !void { + for (steps) |s| { + var cmd: [16]u8 = undefined; + try testing.expectEqual(Status.ok, wr(q, root_exec, try std.fmt.bufPrint(&cmd, "{s}\n", .{s.word})).reply.status); + q.sync(); + const pane = q.panes[q.active].?; + try testing.expect(std.mem.endsWith(u8, pane.file.?.path, s.file)); + try testing.expectEqual(s.line, pane.body.cur_row + 1); + } + } + }.run; + // a's places first, b only once a has none older; Forward mirrors it + // from b and ends at a80, where it began. + try walk(p, &.{ + .{ .word = "Back", .file = "/a.txt", .line = 40 }, + .{ .word = "Back", .file = "/a.txt", .line = 1 }, + .{ .word = "Back", .file = "/b.txt", .line = 1 }, + .{ .word = "Forward", .file = "/b.txt", .line = 40 }, + .{ .word = "Forward", .file = "/b.txt", .line = 80 }, + .{ .word = "Forward", .file = "/a.txt", .line = 80 }, + }); + try testing.expectEqual(Status.ok, wr(p, @intFromEnum(tree.TopFile.ctl), "JumpScope all\n").reply.status); + try testing.expect(std.mem.indexOf(u8, rd(p, @intFromEnum(tree.TopFile.ctl), 0, 8192).bytes, "JumpScope all\n") != null); + try walk(p, &.{ + .{ .word = "Back", .file = "/b.txt", .line = 80 }, + .{ .word = "Back", .file = "/a.txt", .line = 40 }, + .{ .word = "Forward", .file = "/b.txt", .line = 80 }, + }); +} + test "Recent keeps only files on disk: not a name never saved, nor the served tree's" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); |
