diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-29 05:33:00 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:16 -0300 |
| commit | 9b623d635b79f97122f512153b974dfa434f85ab (patch) | |
| tree | 31b6c502d4777c64ef5315260f1a560718bb259c /src/look.zig | |
| parent | 2fe2c920513fc78b61039714bf4d11ae48169f40 (diff) | |
| download | pardes-9b623d635b79f97122f512153b974dfa434f85ab.tar.gz pardes-9b623d635b79f97122f512153b974dfa434f85ab.zip | |
@p names a pane by its serial, as /index and the log do
A +Search row for a pane with no path (a terminal's), a jump list row and
a line-number look said @p<slot>, the pane's place in the core's table,
which no client can see. They now say @p<serial>, and @p resolves a
serial. Re-recorded by name, their diffs checked: jumps, ttylook and
psearch (whose waits now say @p1) for @p<serial>, and with them argv,
nested, reflow, tinywin, ttyhelp and ttyonly for the boot scratch now
named <cwd>/+New (the change before).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/look.zig')
| -rw-r--r-- | src/look.zig | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/look.zig b/src/look.zig index 86238413..d53ac76a 100644 --- a/src/look.zig +++ b/src/look.zig @@ -360,7 +360,12 @@ pub fn resolve(p: ?*pardes.Pardes, word_raw: []const u8, cwd: []const u8, realbu for (word[config.pane_addr.len..]) |c| { if (!std.ascii.isDigit(c)) break; id = id *| 10 +| (c - '0'); - } else return .{ .pane = .{ .id = id, .at = pl.at } }; + } else { + // `@p<serial>`: the pane's serial, as /index and the log name + // it, not its slot; one that is not open names none. + const slot = if (p) |pp| (pp.paneBySerial(@intCast(@min(id, std.math.maxInt(u32)))) orelse MAX_PANES) else id; + return .{ .pane = .{ .id = slot, .at = pl.at } }; + } } for (config.url_schemes) |scheme| { @@ -635,7 +640,7 @@ pub fn runSearch(p: *Pardes, id: usize, pat_raw: []const u8, kind: Search, start const loc: []const u8 = if (has_path) std.fs.path.basename(pane.file.?.path) else - std.fmt.bufPrint(&idbuf, config.pane_addr ++ "{d}", .{id}) catch return error.PathTooLong; + std.fmt.bufPrint(&idbuf, config.pane_addr ++ "{d}", .{pane.serial}) catch return error.PathTooLong; const cl: usize = @intCast(@max(0, pane.body.cur_row)); const cc: usize = @intCast(@max(0, pane.body.cur_col)); for (lines, 0..) |ln, i| { @@ -1133,7 +1138,7 @@ fn canonicalLookLocation(p: *Pardes, id: usize, text: []const u8) ?[]const u8 { if (comptime pdf_enabled) if (pane.pdf) |doc| return locationText(p, doc.path, target.at); if (pane.image) |iv| return locationText(p, iv.path, target.at); var path: [32]u8 = undefined; - return locationText(p, std.fmt.bufPrint(&path, config.pane_addr ++ "{d}", .{target.id}) catch return null, target.at); + return locationText(p, std.fmt.bufPrint(&path, config.pane_addr ++ "{d}", .{pane.serial}) catch return null, target.at); }, } } @@ -1641,6 +1646,16 @@ test "Look copies its operand before releasing pointer selection storage" { try std.testing.expectEqual(.none, p.drag); } +test "@p names a pane by its serial, as /index does" { + const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 }); + defer p.deinit(); + const pane = try p.setTestFile("alpha\nbravo\n"); + var realbuf: [4096]u8 = undefined; + var word: [32]u8 = undefined; + const target = resolve(p, try std.fmt.bufPrint(&word, config.pane_addr ++ "{d}:2", .{pane.serial}), "/", &realbuf); + try std.testing.expectEqual(p.paneBySerial(pane.serial).?, target.pane.id); +} + test "Look ignores missing and out of bounds pane addresses" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 }); defer p.deinit(); |
