From d1d5d3cfb18841604bba2057eeb3598f729b4475 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 02:56:53 -0300 Subject: client #1, the views indexed: a view's share of the session is Pardes.View (the ~42 fields views.fields named: size, cell metrics, columns, rects, focus, jumps, pointer, gestures, prefixes, frontend), one of Pardes.views[4] (null when closed), the live one views[live] through Pardes.view() (index field `view` renamed `live`); going into another view is the index plus the panes' shares, which stay swapped (park and unpark now move only Pane.pv); views.zig loses fields, Part over Pardes, Parked, kept, emptied and the session half of every copy, and a pane closing leaves every view's layout at once (views.gone, at the two places a slot is freed) instead of the serials each parked view kept; drawOne and within put the drawn view's own share back whole; the views are in the digest now (tape's per-field parts name views[k].field), so a fresh view's col_x/col_w default to zeros, not undefined; the dump keeps every open view in the core and the panes' shares of the others under `shares`; an image from before (live view as the core's own fields, the rest under `views`) loads them into views[] once; the ~2,400 references rewritten mechanically from the compiler's errors (p.active is p.view().active, `const v = p.view()` hoisted in 823 places), Kind.zig (4 lines) and addon_test.zig (3) among them, macos.zig by pattern (not compiled here); tape's watched host writes read the live view's frontend and active; perf.zig's accessor lines change its harness hash, the debug baselines re-keyed to it (their numbers the base's); no golden changes; gates: core-test 956/956 both, unit-test 1487/1488 tui and 1530/1531 gui, behaviour-test 248/248 both, pane-test 171/172, snap all 105 ok, process-test 0 of 37 failed tui, replicas ok Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/edit_cmd.zig | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/edit_cmd.zig') diff --git a/src/edit_cmd.zig b/src/edit_cmd.zig index 99cac6ce..207dd7cc 100644 --- a/src/edit_cmd.zig +++ b/src/edit_cmd.zig @@ -96,11 +96,11 @@ const World = struct { return said(sam.File, why, "B: {s} is a directory", .{path}); // A look opens it, or finds it open, where a look would; the // keyboard stays where the Edit ran. - const was = p.active; + const was = p.view().active; p.look_text = true; look.lookAt(p, w.from, path); p.look_text = false; - if (p.panes[was] != null) p.active = was; + if (p.panes[was] != null) p.view().active = was; for (p.panes, 0..) |slot, id| { const pane = slot orelse continue; const f = ninep_pane.fileOf(pane) orelse continue; @@ -310,7 +310,7 @@ pub fn finish(p: *Pardes, success: bool, outputs: []const []const u8, failure: ? const pd = p.pipe.edit_run orelse return; p.pipe.edit_run = null; defer pd.deinit(p.gpa); - const at = if (p.panes[pd.origin]) |pane| (if (pane.serial == pd.origin_serial) pd.origin else p.active) else p.active; + const at = if (p.panes[pd.origin]) |pane| (if (pane.serial == pd.origin_serial) pd.origin else p.view().active) else p.view().active; // Whatever fails from here fails the 9P write that ran it too. const failures = p.fs.failures; defer answerHold(p, at, p.fs.failures != failures); @@ -329,9 +329,9 @@ pub fn finish(p: *Pardes, success: bool, outputs: []const []const u8, failure: ? Pipe.writeFailure(w, failure) catch break :report; const why = std.mem.sliceTo(out.written()[why_at..], '\n'); const said = std.fmt.bufPrint(&line, "Edit: {c} {s}: {s}", .{ job.c, job.command[0..@min(job.command.len, 120)], why }) catch "Edit: a command failed"; - const was = p.active; + const was = p.view().active; _ = ninep_pane.appendErrors(p, at, out.written()); - if (p.panes[was] != null) p.active = was; + if (p.panes[was] != null) p.view().active = was; return p.reportFailure(at, said); } p.reportFailure(at, "Edit: a command failed"); @@ -341,7 +341,7 @@ pub fn finish(p: *Pardes, success: bool, outputs: []const []const u8, failure: ? /// of it, if a pane it changes is not the one it read any more. fn commit(p: *Pardes, pd: *Pending, outputs: []const []const u8) void { const res = pd.res; - const at = if (p.panes[pd.origin]) |pane| (if (pane.serial == pd.origin_serial) pd.origin else p.active) else p.active; + const at = if (p.panes[pd.origin]) |pane| (if (pane.serial == pd.origin_serial) pd.origin else p.view().active) else p.view().active; var text: [320]u8 = undefined; for (res.files, 0..) |f, i| { if (f.ops.items.len == 0 and !f.close and !f.renamed and !f.moved and f.get == null) continue; @@ -429,9 +429,9 @@ fn commit(p: *Pardes, pd: *Pending, outputs: []const []const u8) void { out.appendSlice(p.gpa, res.printed[from..]) catch return; // Printed, the keyboard stays where it was: a +Errors made for it // does not take it, so the next Edit lands where this one did. - const was = p.active; + const was = p.view().active; if (out.items.len > 0) _ = ninep_pane.appendErrors(p, at, out.items); - if (p.panes[was] != null) p.active = was; + if (p.panes[was] != null) p.view().active = was; } if (refused.written().len > 0) { var said: [320]u8 = undefined; @@ -572,7 +572,7 @@ test "Edit's < | and > with a real shell: a command per address, > printed to +E try testing.expectEqual(tree.Status.ok, th.wr(p, ctl, "Edit , > wc -l\n").reply.status); try runReal(p); // The +Errors it opened did not take the keyboard. - try testing.expectEqual(@as(usize, 0), p.active); + try testing.expectEqual(@as(usize, 0), p.view().active); try testing.expectEqualStrings("ONE TWO\nnew", p.panes[0].?.file.?.content); try testing.expectEqualStrings("1", std.mem.trim(u8, errorsText(p).?, " \n")); } @@ -621,9 +621,9 @@ test "X over open files, w, e, r, f, B and D on panes and the disk" { defer p.deinit(); var path: [4200]u8 = undefined; look.lookAt(p, 0, try std.fmt.bufPrint(&path, "{s}/a.c", .{dir})); - const a = p.active; + const a = p.view().active; look.lookAt(p, 0, try std.fmt.bufPrint(&path, "{s}/b.h", .{dir})); - p.active = 0; + p.view().active = 0; const ctl = tree.Node.of(th.serialOf(p), .ctl); // X: every open file whose line matches, each from its own dot. try testing.expectEqual(tree.Status.ok, th.wr(p, ctl, "Edit X/\\.[ch]$/ ,s/foo/FOO/g\n").reply.status); @@ -637,7 +637,7 @@ test "X over open files, w, e, r, f, B and D on panes and the disk" { // B opens a file, which a `"re"` address then edits, from pane 0. var cmd: [4400]u8 = undefined; try testing.expectEqual(tree.Status.ok, th.wr(p, ctl, try std.fmt.bufPrint(&cmd, "Edit B {s}/c.c\n", .{dir})).reply.status); - try testing.expectEqual(@as(usize, 0), p.active); + try testing.expectEqual(@as(usize, 0), p.view().active); try testing.expectEqual(tree.Status.ok, th.wr(p, ctl, "Edit \"c\\.c$\" 1 s/bar/BAR/\n").reply.status); const c = for (p.panes, 0..) |slot, i| { if (slot) |q| if (q.file) |f| if (std.mem.endsWith(u8, f.path, "/c.c")) break i; @@ -694,10 +694,10 @@ test "an Edit's w to a file changed on disk is refused once, as Save is, and the defer p.deinit(); var path: [4200]u8 = undefined; look.lookAt(p, 0, try std.fmt.bufPrint(&path, "{s}/a.txt", .{dir})); - const a = p.active; + const a = p.view().active; look.lookAt(p, 0, try std.fmt.bufPrint(&path, "{s}/b.txt", .{dir})); - const b = p.active; - p.active = 0; + const b = p.view().active; + p.view().active = 0; for ([_]usize{ a, b }) |i| try testing.expectEqual(tree.Status.ok, th.wr(p, tree.Node.of(p.panes[i].?.serial, .ctl), "Edit $a/more/\n").reply.status); // a.txt changed on disk since it was read (the watch says so). p.panes[a].?.file.?.disk_newer = 1; @@ -729,8 +729,8 @@ test "an Edit with no command runs beside one whose commands run, unless it touc defer p.deinit(); var path: [4200]u8 = undefined; look.lookAt(p, 0, try std.fmt.bufPrint(&path, "{s}/other.txt", .{dir})); - const other = p.active; - p.active = 0; + const other = p.view().active; + p.view().active = 0; const ctl = tree.Node.of(th.serialOf(p), .ctl); const other_ctl = tree.Node.of(p.panes[other].?.serial, .ctl); try testing.expectEqual(tree.Status.ok, th.wr(p, ctl, "Edit , | sort\n").reply.status); -- cgit v1.3