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 | |
| 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')
| -rw-r--r-- | src/Output.zig | 2 | ||||
| -rw-r--r-- | src/look.zig | 21 | ||||
| -rw-r--r-- | src/mouse.zig | 2 |
3 files changed, 20 insertions, 5 deletions
diff --git a/src/Output.zig b/src/Output.zig index ee932768..b32a40a2 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -499,7 +499,7 @@ pub fn openJumps(p: *Pardes, id: usize) !void { const loc: []const u8 = if (has_path) (if (jp.file) |f| f.path else pdf_path.?) else - std.fmt.bufPrint(&idbuf, config.pane_addr ++ "{d}", .{j.pane}) catch unreachable; + std.fmt.bufPrint(&idbuf, config.pane_addr ++ "{d}", .{jp.serial}) catch unreachable; const what: []const u8 = if (jp.file) |f| std.mem.trim(u8, modal.lineSlice(f.content, j.line -| 1), " \t\r") else if (jp.image) |iv| 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(); diff --git a/src/mouse.zig b/src/mouse.zig index 0d1bfadd..cb5512ad 100644 --- a/src/mouse.zig +++ b/src/mouse.zig @@ -1032,7 +1032,7 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void { if (line >= 0) { pane.sel[b].state = .none; var buf: [48]u8 = undefined; - const target = std.fmt.bufPrint(&buf, "@p{d}:{d}", .{ s.id, @as(usize, @intCast(line)) + 1 }) catch return; + const target = std.fmt.bufPrint(&buf, "@p{d}:{d}", .{ pane.serial, @as(usize, @intCast(line)) + 1 }) catch return; exec.runBuiltin(p, config.look_cmd, s.id, "", target); return; } |
