summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 05:33:00 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit9b623d635b79f97122f512153b974dfa434f85ab (patch)
tree31b6c502d4777c64ef5315260f1a560718bb259c
parent2fe2c920513fc78b61039714bf4d11ae48169f40 (diff)
downloadpardes-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]>
-rw-r--r--src/Output.zig2
-rw-r--r--src/look.zig21
-rw-r--r--src/mouse.zig2
-rw-r--r--test/snapshots/argv.golden2
-rw-r--r--test/snapshots/jumps.golden4
-rw-r--r--test/snapshots/nested.golden6
-rw-r--r--test/snapshots/psearch.golden10
-rw-r--r--test/snapshots/psearch.snap8
-rw-r--r--test/snapshots/reflow.golden2
-rw-r--r--test/snapshots/tinywin.golden18
-rw-r--r--test/snapshots/ttyhelp.golden2
-rw-r--r--test/snapshots/ttylook.golden2
-rw-r--r--test/snapshots/ttyonly.golden4
13 files changed, 49 insertions, 34 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;
}
diff --git a/test/snapshots/argv.golden b/test/snapshots/argv.golden
index ab143a88..e4d41d6c 100644
--- a/test/snapshots/argv.golden
+++ b/test/snapshots/argv.golden
@@ -20,7 +20,7 @@
|
|
|
-| /+New Save Tty Collapse Del
+| /tmp/pardes-snap/argv/cwd/+New Save Tty Collapse Del
| 1
== snap filearg grid=100x31 cursor=7,3
|Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Exit
diff --git a/test/snapshots/jumps.golden b/test/snapshots/jumps.golden
index 96ba2cc5..764269ce 100644
--- a/test/snapshots/jumps.golden
+++ b/test/snapshots/jumps.golden
@@ -134,9 +134,9 @@
== snap jumplist grid=150x31 cursor=7,17
|3: 86 line 86 Jumplist ls
|16: /tmp/pardes-snap/jumps/cwd/+Jumps Save Tty Collapse Del LocationsConfig
-|17: 1 @p1:3:3 /tmp/pardes-snap/jumps/cwd
+|17: 1 @p2:3:3 /tmp/pardes-snap/jumps/cwd
|18: 2 /tmp/pardes-snap/jumps/cwd/big.txt:1:1 line 1
-|19: 3 @p1:3:3 /tmp/pardes-snap/jumps/cwd
+|19: 3 @p2:3:3 /tmp/pardes-snap/jumps/cwd
|20: 4 /tmp/pardes-snap/jumps/cwd/big.txt:100:1 line 100
|21: 5
|22:
diff --git a/test/snapshots/nested.golden b/test/snapshots/nested.golden
index e5244e71..9758c491 100644
--- a/test/snapshots/nested.golden
+++ b/test/snapshots/nested.golden
@@ -20,7 +20,7 @@
|
|
|
-| /+New Save Tty Collapse Del
+| /tmp/pardes-snap/nested/cwd/+New Save Tty Collapse Del
| 1
== snap no-arg grid=100x31 cursor=4,7
|Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Exit
@@ -44,7 +44,7 @@
|
|
|
-| /+New Save Tty Collapse Del
+| /tmp/pardes-snap/nested/cwd/+New Save Tty Collapse Del
| 1
== snap dir-arg grid=100x31 cursor=4,8
|Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Exit
@@ -68,5 +68,5 @@
|
|
|
-| /+New Save Tty Collapse Del
+| /tmp/pardes-snap/nested/cwd/+New Save Tty Collapse Del
| 1
diff --git a/test/snapshots/psearch.golden b/test/snapshots/psearch.golden
index 228096ba..1ac01c0d 100644
--- a/test/snapshots/psearch.golden
+++ b/test/snapshots/psearch.golden
@@ -20,18 +20,18 @@
|
|
|
-| /+New Save Tty Collapse Del
+| /tmp/pardes-snap/psearch/cwd/+New Save Tty Collapse Del
| 1
== snap typing grid=140x31 cursor=139,3
|3: printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' /MARK
== snap results grid=140x31 cursor=7,4
|3: printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n'
|10: /tmp/pardes-snap/psearch/cwd/+Search Save Tty Collapse Del LocationsConfig
-|11: 1 @p0:2:3-6
+|11: 1 @p1:2:3-6
|12: 2 x MARK a
-|13: 3 @p0:4:3-6
+|13: 3 @p1:4:3-6
|14: 4 x MARK b
-|15: 5 @p0:6:3-6
+|15: 5 @p1:6:3-6
|16: 6 x MARK c
|17: 7
== style results grid=140x31
@@ -56,7 +56,7 @@
|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410,
|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410,
|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410,
-|21: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-3 #b2c3b8,#1d2824, 4-7 #d3b0d9,#1d2824, 8-29 #b2c3b8,#1d2824, 30-139 d,#1d2824,
+|21: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-31 #b2c3b8,#1d2824, 32-35 #d3b0d9,#1d2824, 36-57 #b2c3b8,#1d2824, 58-139 d,#1d2824,
|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410,
|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410,
|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-139 d,#0d1410,
diff --git a/test/snapshots/psearch.snap b/test/snapshots/psearch.snap
index a46e2b9d..6e463119 100644
--- a/test/snapshots/psearch.snap
+++ b/test/snapshots/psearch.snap
@@ -1,7 +1,7 @@
# `/` search on a TERMINAL pane: the same tag input as a file pane, searching
# the shell's own scrollback (the plain text view Look reads, prompt rows
# hidden). Results land in a +Search OUTPUT BUFFER — a file pane with no file
-# behind it, so its tag has no Save — and point at `@p0:LINE:COL-ENDCOL`, the
+# behind it, so its tag has no Save — and point at `@p1:LINE:COL-ENDCOL` (the terminal's serial), the
# look target that names a live pane, since a terminal has no path. n/N SELECT
# the next/prev row in the buffer and open nothing; Enter — the look chord —
# is what scrolls the terminal to that line of its scrollback and selects the
@@ -31,12 +31,12 @@ stable 400 5000
text MARK
stable 400 5000
snap typing
-# Enter opens the results buffer — three @p0:LINE:COL rows — and goes to the
+# Enter opens the results buffer — three @p1:LINE:COL rows — and goes to the
# first of them: the terminal's cursor lands on that scrollback line, on the
# matched SPAN (cols 3..6, past the leading "x ") — not the start of the line,
# and selected rather than merely parked on. No `n` was pressed to get here.
key enter
-wait 10000 @p0:2:3
+wait 10000 @p1:2:3
stable 700 15000
snap results
snapstyle results
@@ -83,6 +83,6 @@ key c-b
stable 600 8000
press right 5 5
release right 5 5
-wait 10000 @p0:2:3
+wait 10000 @p1:2:3
stable 700 15000
snap rightsearch
diff --git a/test/snapshots/reflow.golden b/test/snapshots/reflow.golden
index ab8bfe9b..afd4b93f 100644
--- a/test/snapshots/reflow.golden
+++ b/test/snapshots/reflow.golden
@@ -16,5 +16,5 @@
| yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
| yyyyyyyyyyyyyyyyyyyyyyyyyyyyyydone
| $
-| /+New Save Tty Collapse Del
+| /tmp/pardes-snap/reflow/cwd/+New Save Tty Collapse Del
| 1
diff --git a/test/snapshots/tinywin.golden b/test/snapshots/tinywin.golden
index d24ab0c5..c847a2f1 100644
--- a/test/snapshots/tinywin.golden
+++ b/test/snapshots/tinywin.golden
@@ -20,13 +20,13 @@
|
|
|
-| /+New Save Tty Collapse Del
+| /tmp/pardes-snap/tinywin/cwd/+New Save Tty Collapse Del
| 1
== snap shrunk grid=60x4 cursor=59,3
|Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor
| New Tty Find Grep Joincol Delcol
|$ /tmp/pardes-snap/tinywin/cwd Tty+bash Save Mode Filter Co
-| /+New Save Tty Collapse Del
+| /tmp/pardes-snap/tinywin/cwd/+New Save Tty Collapse Del
== snap columns grid=100x31 cursor=23,3
|Newcol Joincol Find Grep Help Changelog Tutor Dump NextColor Debug Exit
| New Tty Find Grep Joincol Delcol
@@ -49,7 +49,7 @@
|
|
|
-| /+New Save Tty Collapse Del
+| /tmp/pardes-snap/tinywin/cwd/+New Save Tty Collapse Del
| 1
== snap narrow grid=4x31 cursor=2,20
|Newc
@@ -74,10 +74,10 @@
| cn
|
| /
-| +
-| N
-| e
-| w
-|
-| S
+| t
+| m
+| p
+| /
+| p
| a
+| r
diff --git a/test/snapshots/ttyhelp.golden b/test/snapshots/ttyhelp.golden
index cd7cb946..8b8d4195 100644
--- a/test/snapshots/ttyhelp.golden
+++ b/test/snapshots/ttyhelp.golden
@@ -20,7 +20,7 @@
|
|
|
-| /+New Save Tty Collapse Del
+| /tmp/pardes-snap/ttyhelp/cwd/+New Save Tty Collapse Del
| 1
== snap helped grid=100x31 cursor=7,6
|5: /tmp/pardes-snap/ttyhelp/cwd/+Help Save Tty Collapse Del
diff --git a/test/snapshots/ttylook.golden b/test/snapshots/ttylook.golden
index ceb32b50..f7a5dc0f 100644
--- a/test/snapshots/ttylook.golden
+++ b/test/snapshots/ttylook.golden
@@ -66,6 +66,6 @@
== snap fileopen grid=120x31 cursor=3,4
|22: /tmp/pardes-snap/ttylook/cwd/+Search Save Tty Collapse De
|23: l LocationsConfig
-|24: 1 @p0:1:1-2
+|24: 1 @p1:1:1-2
|25: 2 ls
|26: 3
diff --git a/test/snapshots/ttyonly.golden b/test/snapshots/ttyonly.golden
index 8c201176..784de4cb 100644
--- a/test/snapshots/ttyonly.golden
+++ b/test/snapshots/ttyonly.golden
@@ -20,7 +20,7 @@
|
|
|
-| /+New Save Tty Collapse Del
+| /tmp/pardes-snap/ttyonly/cwd/+New Save Tty Collapse Del
| 1
== style ttyonly grid=100x31
|0: 0-70 #b2c3b8,#1d2824, 71-99 d,#1d2824,
@@ -44,7 +44,7 @@
|18: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410,
|19: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410,
|20: 0-0 d,#608269, 1-1 d,#0d1410, 2-99 #e5eee5,#0d1410,
-|21: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-3 #b2c3b8,#1d2824, 4-7 #d3b0d9,#1d2824, 8-29 #b2c3b8,#1d2824, 30-99 d,#1d2824,
+|21: 0-1 #ffffff,#496656, 2-2 d,#1d2824, 3-31 #b2c3b8,#1d2824, 32-35 #d3b0d9,#1d2824, 36-57 #b2c3b8,#1d2824, 58-99 d,#1d2824,
|22: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410,
|23: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410,
|24: 0-0 d,#608269, 1-1 d,#0d1410, 2-6 #59675c,#0d1410, 7-99 d,#0d1410,