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/ninep/cols.zig | 81 +++++++++++++++++++++++---------------------- src/ninep/ctl.zig | 93 +++++++++++++++++++++++++++------------------------- src/ninep/events.zig | 10 +++--- src/ninep/pane.zig | 2 +- src/ninep/screen.zig | 8 ++--- src/ninep/tree.zig | 34 +++++++++---------- 6 files changed, 116 insertions(+), 112 deletions(-) (limited to 'src/ninep') diff --git a/src/ninep/cols.zig b/src/ninep/cols.zig index 20ee2e3e..74d1f668 100644 --- a/src/ninep/cols.zig +++ b/src/ninep/cols.zig @@ -20,8 +20,8 @@ const E = tree.E; /// else the active pane's. Null when the workspace tag has it and no pane /// is active. pub fn activeColumn(p: *const Pardes) ?usize { - if (p.headerColumn()) |c| return if (c < p.ncol) c else null; - const at = layout.findPane(p, p.active) orelse return null; + if (p.headerColumn()) |c| return if (c < p.view().ncol) c else null; + const at = layout.findPane(p, p.view().active) orelse return null; return at.col; } @@ -32,13 +32,14 @@ pub fn activeColumn(p: *const Pardes) ?usize { /// then `active `: the active column, where pane/new and a look /// place a pane next (acme's activecol), not always the keyboard's. pub fn writeLayout(p: *Pardes, w: *std.Io.Writer) !void { + const v = p.view(); const active = activeColumn(p); - for (0..p.ncol) |c| { + for (0..p.view().ncol) |c| { try w.print("{d} {d} {d} {d} {s} {s}", .{ - layout.columnSerial(p, c), c, p.col_x[c], p.col_w[c], - if (active == c) "current" else "notcurrent", if (p.cols[c].n == 0) "empty" else "full", + layout.columnSerial(p, c), c, v.col_x[c], v.col_w[c], + if (active == c) "current" else "notcurrent", if (v.cols[c].n == 0) "empty" else "full", }); - for (p.cols[c].panes[0..p.cols[c].n]) |id| if (p.panes[id]) |pane| try w.print(" {d}", .{pane.serial}); + for (v.cols[c].panes[0..p.view().cols[c].n]) |id| if (p.panes[id]) |pane| try w.print(" {d}", .{pane.serial}); try w.writeByte('\n'); } if (layout.activeColumn(p) orelse active) |c| try w.print("active {d}\n", .{layout.columnSerial(p, c)}) else try w.writeAll("active -\n"); @@ -51,7 +52,7 @@ const Header = struct { text: *Text, col: ?usize }; fn header(p: *Pardes, serial: ?u32) ?Header { const s = serial orelse return .{ .text = &p.global_tag, .col = null }; const c = layout.columnBySerial(p, s) orelse return null; - return .{ .text = &p.col_tags[c], .col = c }; + return .{ .text = &p.view().col_tags[c], .col = c }; } pub fn headerText(p: *Pardes, serial: ?u32) ?[]const u8 { @@ -174,7 +175,7 @@ pub fn writeCtl(p: *Pardes, req: Req, serial: u32) Reply { defer p.exec_column = null; p.exec_header = true; defer p.exec_header = false; - if (pardes.ctlfs.ctl.runBuiltin(p, req, p.active, line)) |refusal| return refusal; + if (pardes.ctlfs.ctl.runBuiltin(p, req, p.view().active, line)) |refusal| return refusal; } return .{ .tag = req.tag, .written = @intCast(req.data.len) }; } @@ -206,7 +207,7 @@ pub fn writeExec(p: *Pardes, req: Req, serial: ?u32) Reply { defer p.exec_column = null; p.exec_header = true; defer p.exec_header = false; - if (pardes.ctlfs.ctl.captured(p, req, p.active, true, line, true)) |refusal| return refusal; + if (pardes.ctlfs.ctl.captured(p, req, p.view().active, true, line, true)) |refusal| return refusal; } return .{ .tag = req.tag, .written = @intCast(req.data.len) }; } @@ -220,7 +221,7 @@ test "New written to a column's exec makes its scratch in the session's director const serial = layout.columnSerial(p, 0); const exec_node = tree.Node.ofCol(serial, .exec); try testing.expectEqual(tree.Status.ok, th.wr(p, exec_node, "New\n").reply.status); - try testing.expectEqualStrings("/project/src/+New", p.panes[p.active].?.file.?.path); + try testing.expectEqualStrings("/project/src/+New", p.panes[p.view().active].?.file.?.path); } test "Joincol is refused when the joined column cannot give each pane its tag and 2 rows" { @@ -237,15 +238,15 @@ test "Joincol is refused when the joined column cannot give each pane its tag an var digits: [16]u8 = undefined; _ = th.wr(p, focus, try std.fmt.bufPrint(&digits, "{d}\n", .{b})); _ = try th.newPane(p); - try testing.expectEqual(@as(usize, 2), p.ncol); - try testing.expect(p.cols[0].n >= 2 and p.cols[1].n >= 2); + try testing.expectEqual(@as(usize, 2), p.view().ncol); + try testing.expect(p.view().cols[0].n >= 2 and p.view().cols[1].n >= 2); // Focus in the left column: joined, four panes want 12 rows of 10. - const left = p.panes[p.cols[0].panes[0]].?.serial; + const left = p.panes[p.view().cols[0].panes[0]].?.serial; _ = th.wr(p, focus, try std.fmt.bufPrint(&digits, "{d}\n", .{left})); const r = th.wr(p, ctl, "Joincol\n"); try testing.expectEqual(tree.Status.err, r.reply.status); try testing.expect(std.mem.indexOf(u8, r.reply.ename, "tag and 2 rows") != null); - try testing.expectEqual(@as(usize, 2), p.ncol); + try testing.expectEqual(@as(usize, 2), p.view().ncol); try testing.expect(pardes.layout.minimaFit(p)); } @@ -253,7 +254,7 @@ test "pane/new takes rows from a pane in another column before refusing ENOSPC" const p = try pardes.Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 16 }); defer p.deinit(); while (p.nextEffect()) |_| {} - const first = p.panes[p.active].?.serial; + const first = p.panes[p.view().active].?.serial; // A second column holding one tall pane. try testing.expectEqual(tree.Status.ok, th.wr(p, @backingInt(tree.TopFile.ctl), "Newcol\n").reply.status); const tall = try th.newPane(p); @@ -311,12 +312,12 @@ test "a Newcol refused because the tags would not fit logs its err alone and spe const made = try th.newPane(p); const pane = p.panes[p.paneBySerial(made).?].?; const col = layout.findPane(p, p.paneBySerial(made).?).?.col; - for (p.cols[col].panes[0..p.cols[col].n]) |k| { + for (p.view().cols[col].panes[0..p.view().cols[col].n]) |k| { const each = p.panes[k].?; if (each.tag.own) |old| p.gpa.free(old); each.tag.own = try p.gpa.dupe(u8, std.mem.asBytes(&@as([60][5]u8, @splat("word ".*)))); } - try testing.expect(p.cols[col].n >= 2); + try testing.expect(p.view().cols[col].n >= 2); p.sync(); const ctl = @backingInt(tree.TopFile.ctl); const focus = @backingInt(tree.TopFile.focus); @@ -354,7 +355,7 @@ test "a tagexec word that makes, acts on and focuses no pane reads back nothing" const col_exec = tree.Node.ofCol(layout.columnSerial(p, 0), .exec); try testing.expectEqual(tree.Status.ok, th.wr(p, col_exec, "New\n").reply.status); var want: [16]u8 = undefined; - try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{p.panes[p.active].?.serial}), th.rd(p, col_exec, 0, 64).bytes); + try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{p.panes[p.view().active].?.serial}), th.rd(p, col_exec, 0, 64).bytes); } test "New written to a column's ctl reads back the new pane alone, as its exec does" { @@ -365,7 +366,7 @@ test "New written to a column's ctl reads back the new pane alone, as its exec d const ctl_node = tree.Node.ofCol(layout.columnSerial(p, 0), .ctl); try testing.expectEqual(tree.Status.ok, th.wr(p, ctl_node, "New\n").reply.status); var want: [16]u8 = undefined; - try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{p.panes[p.active].?.serial}), th.rd(p, root_exec, 0, 64).bytes); + try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{p.panes[p.view().active].?.serial}), th.rd(p, root_exec, 0, 64).bytes); } /// Whether `line` names a builtin that acts on a pane (every one of pane @@ -412,7 +413,7 @@ test "Help and Find at /tagexec act in the session's directory, not the keyboard const tagexec = @backingInt(tree.TopFile.tagexec); for ([_][]const u8{ "Help\n", "Find needle\n" }) |line| { try testing.expectEqual(tree.Status.ok, th.wr(p, tagexec, line).reply.status); - const made = p.panes[p.active].?.file.?.path; + const made = p.panes[p.view().active].?.file.?.path; try testing.expectEqualStrings(session, std.fs.path.dirname(made).?); } } @@ -421,11 +422,11 @@ test "a shell command at /tagexec or a column's exec is a command pane in the se const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 30 }); defer p.deinit(); while (p.nextEffect()) |_| {} - const term = p.panes[p.active].?; - try testing.expect(pardes.exec.takesCommandLine(p, p.active)); + const term = p.panes[p.view().active].?; + try testing.expect(pardes.exec.takesCommandLine(p, p.view().active)); const col_exec = tree.Node.ofCol(layout.columnSerial(p, 0), .exec); for ([_]u64{ @backingInt(tree.TopFile.tagexec), col_exec }) |node| { - p.active = p.paneBySerial(term.serial).?; + p.view().active = p.paneBySerial(term.serial).?; const before = p.next_serial; const r = th.wr(p, node, "echo from-the-tag\n"); try testing.expectEqual(tree.Status.ok, r.reply.status); @@ -449,8 +450,8 @@ test "New and Term run at /tagexec and a column's exec, with no pane at all too" }; // Every pane gone: the workspace tag makes one all the same. for ([_][]const u8{ "New\n", "Term\n" }) |line| { - while (p.ncol > 0) { - const first = p.panes[p.cols[0].panes[0]].?.serial; + while (p.view().ncol > 0) { + const first = p.panes[p.view().cols[0].panes[0]].?.serial; _ = th.wr(p, tree.Node.of(first, .ctl), "delete\n"); if (panes.anyPane(p) == null) break; } @@ -495,7 +496,7 @@ test "every pane word a tag no pane owns does not hold is refused there, Edit in pub fn remove(p: *Pardes, req: Req, serial: u32, file: tree.ColFile) Reply { if (file != .dir) return Reply.fail(req.tag, E.PERM); const col = layout.columnBySerial(p, serial) orelse return Reply.fail(req.tag, E.NOENT); - if (p.cols[col].n > 0) return tree.failText(req.tag, E.NOTEMPTY, "column not empty: close its panes, or write Delcol to its ctl"); + if (p.view().cols[col].n > 0) return tree.failText(req.tag, E.NOTEMPTY, "column not empty: close its panes, or write Delcol to its ctl"); layout.removeColumn(p, col) catch return Reply.fail(req.tag, E.IO); return .{ .tag = req.tag }; } @@ -509,7 +510,7 @@ const Node = tree.Node; test "layout lists each column's place, panes and state, and the active one" { const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); - layout.newColumn(p, p.active); + layout.newColumn(p, p.view().active); p.sync(); const first_serial = layout.columnSerial(p, 0); const new_serial = layout.columnSerial(p, 1); @@ -517,7 +518,7 @@ test "layout lists each column's place, panes and state, and the active one" { const layout_node = @backingInt(tree.TopFile.layout); const text = th.rd(p, layout_node, 0, 4096).bytes; var want: [256]u8 = undefined; - const first = try std.fmt.bufPrint(&want, "{d} 0 {d} {d} notcurrent full {d}\n", .{ first_serial, p.col_x[0], p.col_w[0], p.panes[0].?.serial }); + const first = try std.fmt.bufPrint(&want, "{d} 0 {d} {d} notcurrent full {d}\n", .{ first_serial, p.view().col_x[0], p.view().col_w[0], p.panes[0].?.serial }); try testing.expect(std.mem.startsWith(u8, text, first)); // Newcol gives the new, empty column's tag the keyboard. try testing.expect(std.mem.indexOf(u8, text, "current empty\n") != null); @@ -564,10 +565,10 @@ test "a focus write makes its pane's column the active one: layout says so and p const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); const left = p.panes[0].?.serial; - layout.newColumn(p, p.active); - panes.newScratchFor(p, p.active, .fs); // fills the new, right column + layout.newColumn(p, p.view().active); + panes.newScratchFor(p, p.view().active, .fs); // fills the new, right column p.sync(); - try testing.expectEqual(@as(usize, 1), layout.findPane(p, p.active).?.col); + try testing.expectEqual(@as(usize, 1), layout.findPane(p, p.view().active).?.col); var digits: [16]u8 = undefined; _ = th.wr(p, @backingInt(tree.TopFile.focus), try std.fmt.bufPrint(&digits, "{d}\n", .{left})); var want: [32]u8 = undefined; @@ -613,11 +614,11 @@ test "a column's ctl and exec act on it as its tag would, and rmdir closes it on const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); const first = layout.columnSerial(p, 0); - layout.newColumn(p, p.active); + layout.newColumn(p, p.view().active); const empty = layout.columnSerial(p, 1); // New on the empty column's ctl fills it, wherever the keyboard is. try testing.expectEqual(tree.Status.ok, th.wr(p, Node.ofCol(empty, .ctl), "New\n").reply.status); - try testing.expectEqual(@as(usize, 1), p.cols[1].n); + try testing.expectEqual(@as(usize, 1), p.view().cols[1].n); try testing.expectEqual(E.INVAL, th.wr(p, Node.ofCol(empty, .ctl), "Exit\n").errno()); var rec: [64]u8 = undefined; try testing.expect(th.logHas(p, try std.fmt.bufPrint(&rec, "err - col/{d}/ctl: unknown control message \"Exit\"", .{empty}))); @@ -630,14 +631,14 @@ test "a column's ctl and exec act on it as its tag would, and rmdir closes it on try testing.expectEqual(tree.Status.ok, th.wr(p, Node.ofCol(empty, .exec), "Delcol\n").reply.status); try testing.expectEqual(@as(?usize, null), layout.columnBySerial(p, empty)); // An empty column goes on rmdir. - layout.newColumn(p, p.active); + layout.newColumn(p, p.view().active); const made = layout.columnSerial(p, 1); try testing.expectEqual(tree.Status.ok, th.call(p, .{ .tag = 2, .op = .release, .node = Node.ofCol(made, .dir), .remove = true }).reply.status); try testing.expectEqual(@as(?usize, null), layout.columnBySerial(p, made)); try testing.expectEqual(first, layout.columnSerial(p, 0)); // Joincol folds a column into the one on its right, which keeps its own // serial and tag. - layout.newColumn(p, p.active); + layout.newColumn(p, p.view().active); const right = layout.columnSerial(p, 1); _ = th.wr(p, Node.ofCol(right, .tag), " Mine"); try testing.expectEqual(tree.Status.ok, th.wr(p, Node.ofCol(first, .ctl), "Joincol\n").reply.status); @@ -654,7 +655,7 @@ test "tagexec runs a word as a click in the workspace tag; exec files read back const tagexec = @backingInt(tree.TopFile.tagexec); try testing.expectEqual(tree.Status.ok, th.look_up(p, tree.root, "tagexec").reply.status); try testing.expectEqual(tree.Status.ok, th.wr(p, tagexec, "Newcol\n").reply.status); - try testing.expectEqual(@as(usize, 2), p.ncol); + try testing.expectEqual(@as(usize, 2), p.view().ncol); // Its announcement is the message row's, never logged; a pane's word // such as Msg is refused there. try testing.expect(!th.logHas(p, "msg - Newcol\n")); @@ -662,7 +663,7 @@ test "tagexec runs a word as a click in the workspace tag; exec files read back // A column's exec makes a pane there and reads it back. const right = layout.columnSerial(p, 1); try testing.expectEqual(tree.Status.ok, th.wr(p, Node.ofCol(right, .exec), "New\n").reply.status); - const made = p.panes[p.cols[1].panes[0]].?.serial; + const made = p.panes[p.view().cols[1].panes[0]].?.serial; var want: [16]u8 = undefined; try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{made}), th.rd(p, Node.ofCol(right, .exec), 0, 64).bytes); try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{made}), th.rd(p, tagexec, 0, 64).bytes); @@ -690,8 +691,8 @@ test "a word run from the workspace's or a column's tag runs in the session's di test "a command run from a column's tag gets its pane in that column, not the last" { const p = try th.withFile(testing.allocator, "x\n"); defer p.deinit(); - layout.newColumn(p, p.active); - panes.newScratchFor(p, p.active, .fs); // fills the new, right column + layout.newColumn(p, p.view().active); + panes.newScratchFor(p, p.view().active, .fs); // fills the new, right column p.sync(); const left = layout.columnSerial(p, 0); try testing.expectEqual(tree.Status.ok, th.wr(p, Node.ofCol(left, .exec), "true\n").reply.status); @@ -716,7 +717,7 @@ test "a column's ctl refuses an unknown word and an argument as the other ctls d const extra = th.wr(p, ctl_node, "New extra\n"); try testing.expectEqual(E.INVAL, extra.errno()); try testing.expect(std.mem.startsWith(u8, extra.reply.ename, "wrong #args")); - try testing.expectEqual(@as(usize, 1), p.cols[0].n); + try testing.expectEqual(@as(usize, 1), p.view().cols[0].n); // A pane's bare answer and a winsize of no size say what they take. try testing.expectEqualStrings("answer takes a choice or -", th.wr(p, Node.of(p.panes[0].?.serial, .ctl), "answer\n").reply.ename); } diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 78fe15c1..9b87d9aa 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -54,6 +54,7 @@ fn noteResult(p: *Pardes, serial: u32) void { /// created; failing that, a look records the pane it focused and an exec /// the pane it acted on (even one it closed). pub fn run(p: *Pardes, id: usize, exec: bool, text: []const u8, in_tag: bool) void { + const v = p.view(); const context = if (p.panes[id]) |pane| pane.serial else 0; // A pane an event reader holds hears its clicks instead of acting on // them (editors/acme/look.c:53 and exec.c:173 send them to winevent), @@ -106,10 +107,10 @@ pub fn run(p: *Pardes, id: usize, exec: bool, text: []const u8, in_tag: bool) vo // A word in a column's or the workspace's tag ran at no pane: it // answers one only if it focused one (Newcol answers nothing). if (p.exec_header) { - if (p.active != id) if (p.panes[p.active]) |pane| noteResult(p, pane.serial); + if (v.active != id) if (p.panes[v.active]) |pane| noteResult(p, pane.serial); return; } - noteResult(p, if (exec) context else (p.panes[p.active] orelse return).serial); + noteResult(p, if (exec) context else (p.panes[v.active] orelse return).serial); } /// A write's messages, a line each, except that an `Edit` line takes the @@ -190,9 +191,10 @@ pub fn completeEnd(p: *Pardes, data: []const u8) usize { /// A null `serial` clicks at whichever pane is active as each line runs, /// which is what the root's own look and exec mean; a serial stays put. pub fn command(p: *Pardes, req: Req, serial: ?u32, exec: bool, in_tag: bool) Reply { + const v = p.view(); // The root's lines run at the keyboard's pane: a refusal before any runs // is that pane's too, in its err record. - p.fs.ran_at = if (serial == null) (if (p.panes[p.active]) |pane| pane.serial else 0) else 0; + p.fs.ran_at = if (serial == null) (if (p.panes[v.active]) |pane| pane.serial else 0) else 0; if (editNotAlone(p, req.data)) return tree.failText(req.tag, E.INVAL, e_after_edit); for ([2]bool{ false, true }) |apply| { if (apply) p.fs.results_len = 0; @@ -204,7 +206,7 @@ pub fn command(p: *Pardes, req: Req, serial: ?u32, exec: bool, in_tag: bool) Rep for (text) |c| if ((c < ' ' and c != '\t' and c != '\n') or c == 0x7f) return tree.failText(req.tag, E.INVAL, e_control); if (exec) if (tooLong(req, text)) |refusal| return refusal; if (!apply) continue; - var id = if (serial) |s| p.paneBySerial(s) orelse break else p.active; + var id = if (serial) |s| p.paneBySerial(s) orelse break else v.active; // No pane at all: the root's look and exec act in the session's // directory. An exec runs as the workspace tag's; a look from a // scratch made as New makes one (and its column), dropped @@ -220,12 +222,12 @@ pub fn command(p: *Pardes, req: Req, serial: ?u32, exec: bool, in_tag: bool) Rep const free = p.freeSlot() orelse return Reply.fail(req.tag, E.NOSPC); panes.newScratchFor(p, id, .scratch); if (p.panes[free] == null) return Reply.fail(req.tag, E.NOSPC); - p.active = free; + v.active = free; id = free; scratch = free; } if (p.panes[id] == null) return Reply.fail(req.tag, E.NOENT); - defer if (scratch) |s| if (p.active != s) if (p.panes[s]) |sp| if (sp.file) |f| { + defer if (scratch) |s| if (v.active != s) if (p.panes[s]) |sp| if (sp.file) |f| { if (f.content.len == 0) p.removePane(s, null) catch {}; }; p.fs.ran_at = p.panes[id].?.serial; @@ -389,7 +391,7 @@ pub fn statusText(p: *Pardes) []const u8 { // Whether the pointer is over this window: what a grip let go past // another window's edge asks of every window, to find the one it was // let go over (Handover.zig), where no window may know another's place. - if (p.frontend.windowed) w.writer.print("pointer {s}\n", .{if (p.pointer_inside) "in" else "out"}) catch {}; + if (p.view().frontend.windowed) w.writer.print("pointer {s}\n", .{if (p.view().pointer_inside) "in" else "out"}) catch {}; return w.written(); } @@ -431,7 +433,7 @@ pub fn paneText(p: *Pardes, pane: *Pane, buf: []u8) []const u8 { const font = p.settings.font.effective_name.get(); writeQuoted(&w, if (font.len == 0) "default" else font) catch return w.buffered(); // While a column's or the workspace's tag has the keyboard, no pane does. - const current = p.panes[p.active] == pane and p.header == null; + const current = p.panes[p.view().active] == pane and p.view().header == null; const f = pane_files.fileOf(pane); const undo = if (f) |file| file.history.journal.done > 0 else false; const redo = if (f) |file| file.history.journal.done < file.history.journal.steps.items.len else false; @@ -684,7 +686,7 @@ pub fn writePager(p: *Pardes, req: Req) Reply { if (pardes.filesystem.deniedAbove(local)) return tree.failText(req.tag, E.PERM, std.fmt.bufPrint(&p.fs.ename, "pager: {s}: permission denied", .{dir[0..@min(dir.len, 256)]}) catch "pager: permission denied"); }; - const id = pardes.panes.Output.openPager(p, p.active, dir) catch |err| + const id = pardes.panes.Output.openPager(p, p.view().active, dir) catch |err| return tree.failText(req.tag, if (err == error.NoPaneRoom or err == error.NoPaneSlots) E.NOSPC else E.IO, switch (err) { error.NoPaneRoom, error.NoPaneSlots => "pager: no space for a +Pager pane", else => "pager: could not make a +Pager pane", @@ -715,12 +717,12 @@ pub fn fillPager(p: *Pardes, serial: u32, held: *std.ArrayList(u8)) error{OutOfM // +Diff in the +Pager's place, the +Pager closed. The keyboard stays // where it was, as a page's. if (f.pager_diff) { - const keyboard = p.active; + const keyboard = p.view().active; if (panes.Output.openDiff(p, id, f.path, f.content)) |hid| { // ponytail: the text is gone with it; Diff on the +Diff says no such file. p.removePane(id, hid) catch {}; } else |_| {} - if (p.panes[keyboard] != null) p.active = keyboard; + if (p.panes[keyboard] != null) p.view().active = keyboard; } } @@ -736,6 +738,7 @@ pub fn fillClosedPagers(p: *Pardes) void { /// One session builtin a line, at whichever pane has the keyboard as each /// runs, as the root's look and exec click there; all are checked first. pub fn writeRoot(p: *Pardes, req: Req) Reply { + const v = p.view(); for ([2]bool{ false, true }) |apply| { if (apply) p.fs.results_len = 0; var it: Messages = .{ .p = p, .data = req.data }; @@ -749,8 +752,8 @@ pub fn writeRoot(p: *Pardes, req: Req) Reply { // attached to (--detach, unattended) takes one written. if (!p.unattended) return refuseQuoting(p, req, "size: a frontend is attached and owns the size", value, ""); if (apply) { - const was: [2]u16 = .{ p.screen_w, p.screen_h }; - const before = p.rects; + const was: [2]u16 = .{ v.screen_w, v.screen_h }; + const before = v.rects; p.update(.{ .resize = .{ .cols = size[0], .rows = size[1] } }); p.sync(); // Every pane keeps its tag and two rows, as placement @@ -785,10 +788,10 @@ pub fn writeRoot(p: *Pardes, req: Req) Reply { continue; } // An empty window (no pane at all) still takes its session words. - if (p.panes[p.active] == null and panes.anyPane(p) != null) return Reply.fail(req.tag, E.NOENT); + if (p.panes[v.active] == null and panes.anyPane(p) != null) return Reply.fail(req.tag, E.NOENT); p.fs.session_write = true; defer p.fs.session_write = false; - if (runBuiltin(p, req, p.active, line)) |refusal| return refusal; + if (runBuiltin(p, req, v.active, line)) |refusal| return refusal; } } return .{ .tag = req.tag, .written = @intCast(req.data.len) }; @@ -923,8 +926,8 @@ pub fn commandsText(p: *Pardes) ![]const u8 { /// rio keeps `current` apart from `unhide`. pub fn readFocus(p: *Pardes, req: Req) Reply { const out = p.fs.stage(p.gpa); - if (p.header != null) return tree.stagedReply(p, req); - const pane = p.panes[p.active] orelse return tree.stagedReply(p, req); + if (p.view().header != null) return tree.stagedReply(p, req); + const pane = p.panes[p.view().active] orelse return tree.stagedReply(p, req); out.print(p.gpa, "{d}\n", .{pane.serial}) catch return Reply.fail(req.tag, E.NOMEM); return tree.stagedReply(p, req); } @@ -937,7 +940,7 @@ pub fn writeFocus(p: *Pardes, req: Req) Reply { // its column becomes the active one, as the user's click there would // make it: pane/new and a look place there next. tagline.exitHeader(p); - p.active = id; + p.view().active = id; if (pardes.layout.findPane(p, id)) |at| p.setActiveColumn(at.col); return .{ .tag = req.tag, .written = @intCast(req.data.len) }; } @@ -1405,11 +1408,11 @@ test "status in a window says whether the pointer is over it" { // there is a terminal's view. const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - p.frontend.windowed = true; + p.view().frontend.windowed = true; var lines = std.mem.tokenizeScalar(u8, rd(p, root_status, 0, 4096).bytes, '\n'); for (0..3) |_| _ = lines.next(); try testing.expectEqualStrings("pointer out", lines.next().?); - p.frontend.windowed = false; + p.view().frontend.windowed = false; } @@ -1591,9 +1594,9 @@ test "a builtin for one kind of pane is refused on another, and still acts on it // Petscii chose; with them, what it chose. for ([_]bool{ false, true }) |art| { doc.addon.?.art.glyph = art; - p.frontend.native_images = false; + p.view().frontend.native_images = false; try testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagPrefix(p, doc), " petscii:on ") != null); - p.frontend.native_images = true; + p.view().frontend.native_images = true; try testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagPrefix(p, doc), if (art) " petscii:on " else " petscii:off ") != null); } } @@ -1650,7 +1653,7 @@ test "a builtin's Verbose announcement is logged only when it succeeds, its fail try testing.expect(!th.logHas(p, said_exit)); // Refused at the keyboard (no write to fail), edited since: the same. f.revision +%= 1; - _ = p.executeBuiltinLine(p.active, "Exit"); + _ = p.executeBuiltinLine(p.view().active, "Exit"); try testing.expect(!th.logHas(p, said_exit)); try testing.expect(!p.quit); // A Save the host could not do, told a step later: the Save goes too. @@ -1919,7 +1922,7 @@ test "Term in a directory that is not there fails and makes no pane; a shell tha // A terminal whose shell the host could not start. _ = wr(p, Node.of(serial, .name), "/tmp/f.txt\n"); try testing.expectEqual(Status.ok, wr(p, Node.of(serial, .ctl), "Term\n").reply.status); - const term = p.active; + const term = p.view().active; p.shellFailed(@intCast(term), error.FileNotFound); const run_node = Node.of(p.panes[term].?.serial, .pty_run); const h = call(p, .{ .tag = 1, .op = .open, .node = run_node, .omode = 2 }).reply.handle; @@ -1997,7 +2000,7 @@ test "a terminal told the directory it already goes by logs no rename" { _ = wr(p, Node.of(serialOf(p), .name), "/tmp/f.txt\n"); try testing.expectEqual(Status.ok, wr(p, Node.of(serialOf(p), .ctl), "Term\n").reply.status); p.update(.tick); // announced - const term = p.active; + const term = p.view().active; // The host says where its shell started: where it was already named. p.setCwd(term, "/tmp"); var rec: [32]u8 = undefined; @@ -2126,7 +2129,7 @@ test "a script whose interpreter is not there: Term refuses it up front, only an test "a language server question that finds nothing, cannot be answered, or is asked of no file fails, and a write to an image's body is refused" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - const id = p.active; + const id = p.view().active; // Asked of a pane that is no file's: at once. _ = wr(p, root_exec, "Recent\n"); const listed = p.paneBySerial(try std.fmt.parseInt(u32, std.mem.trimEnd(u8, rd(p, root_exec, 0, 64).bytes, "\n"), 10)).?; @@ -2212,7 +2215,7 @@ test "a PDF's body reads its page's text layer, and takes no write" { var line: [4200]u8 = undefined; _ = wr(p, root_look, try std.fmt.bufPrint(&line, "{s}/doc.pdf\n", .{dir})); p.sync(); - const doc = p.panes[p.active].?; + const doc = p.panes[p.view().active].?; try testing.expect(doc.hasPdf()); const body = Node.of(doc.serial, .body); try testing.expect(std.mem.indexOf(u8, rd(p, body, 0, 4096).bytes, "target.txt") != null); @@ -2226,7 +2229,7 @@ test "a PDF's body reads its page's text layer, and takes no write" { test "workspace symbols, Symbols and Diagnostics share their directory's one +Search" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - const id = p.active; + const id = p.view().active; const Output = pardes.panes.Output; try Output.fillResults(p, id, "/tmp", .{ .query = .workspace_symbols }, "x", try p.gpa.dupe(u8, "a.txt:1:1 x\n"), null); try Output.fillResults(p, id, "/tmp", .{ .query = .document_symbols }, "", try p.gpa.dupe(u8, "a.txt:2:1 fn f\n"), null); @@ -2256,7 +2259,7 @@ test "a failure said while a 9P write waits on it posts no msg, only the write's const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); p.fs.write_waits = true; - p.saveFailed(@intCast(p.active), "/nowhere/zz.txt", error.FileNotFound); + p.saveFailed(@intCast(p.view().active), "/nowhere/zz.txt", error.FileNotFound); p.fs.write_waits = false; try testing.expect(!th.logHas(p, "msg ")); try testing.expect(p.fs.late_failure_len > 0); @@ -2337,14 +2340,14 @@ test "a focus moved over 9P tells the programs that asked for focus reports, as n += 1; }; try testing.expectEqual(@as(usize, 2), n); - p.active = shells[0]; + p.view().active = shells[0]; p.update(.{ .output = .{ .pane = @intCast(shells[0]), .bytes = "\x1b[?1004h" } }); p.update(.{ .output = .{ .pane = @intCast(shells[1]), .bytes = "\x1b[?1004h" } }); while (p.nextEffect()) |_| {} var digits: [16]u8 = undefined; const moved = wr(p, @backingInt(tree.TopFile.focus), try std.fmt.bufPrint(&digits, "{d}\n", .{p.panes[shells[1]].?.serial})); try testing.expectEqual(Status.ok, moved.reply.status); - try testing.expectEqual(shells[1], p.active); + try testing.expectEqual(shells[1], p.view().active); try testing.expectEqualStrings("\x1b[O\x1b[I", moved.pty_buf[0..moved.pty_len]); } @@ -2402,14 +2405,14 @@ test "a column takes panes until their documented minimums fill it, not until no const new = @backingInt(tree.TopFile.new); while (call(p, .{ .tag = 1, .op = .open, .node = new }).reply.status == .ok) p.sync(); p.sync(); - const avail = p.screen_h - (p.topBarHeight() + layout.columnBarHeight(p)); - for (0..p.ncol) |c| { + const avail = p.view().screen_h - (p.topBarHeight() + layout.columnBarHeight(p)); + for (0..p.view().ncol) |c| { var need: u32 = 0; - for (p.cols[c].panes[0..p.cols[c].n]) |k| need += layout.minRows(p, k); + for (p.view().cols[c].panes[0..p.view().cols[c].n]) |k| need += layout.minRows(p, k); // Refused only when one more pane's tag and two rows would not fit. - if (p.cols[c].n > 1) try testing.expect(avail - need < 3); + if (p.view().cols[c].n > 1) try testing.expect(avail - need < 3); // Every pane keeps its minimum. - for (p.cols[c].panes[0..p.cols[c].n]) |k| try testing.expect(p.rects[k].h >= layout.minRows(p, k)); + for (p.view().cols[c].panes[0..p.view().cols[c].n]) |k| try testing.expect(p.view().rects[k].h >= layout.minRows(p, k)); } } @@ -2461,7 +2464,7 @@ test "size is monotonic: growing is never refused, and a size once taken is take // until a column has no room (ENOSPC). try testing.expectEqual(Status.ok, wr(p, root_ctl, "Newcol\n").reply.status); for (0..3) |_| try testing.expectEqual(Status.ok, call(p, .{ .tag = 1, .op = .open, .node = new }).reply.status); - try testing.expectEqual(Status.ok, wr(p, Node.of(p.panes[p.active].?.serial, .ctl), "Term\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, Node.of(p.panes[p.view().active].?.serial, .ctl), "Term\n").reply.status); p.sync(); while (call(p, .{ .tag = 1, .op = .open, .node = new }).reply.status == .ok) p.sync(); p.sync(); @@ -2485,7 +2488,7 @@ test "size is monotonic: growing is never refused, and a size once taken is take } for ([_]u16{ 60, 61, 64, 70, 100 }) |grown| { try testing.expectEqual(Status.ok, wr(p, root_ctl, try std.fmt.bufPrint(&line, "size 160 {d}\n", .{grown})).reply.status); - try testing.expectEqual(grown, p.screen_h); + try testing.expectEqual(grown, p.view().screen_h); } // Out of range is EINVAL, in words 9ns reads as that. const bad = wr(p, root_ctl, "size 5 2\n"); @@ -2587,11 +2590,11 @@ test "Newcol at the column cap fails the write and says the cap" { defer p.deinit(); p.update(.{ .resize = .{ .cols = 4000, .rows = 30 } }); const root_ctl = @backingInt(tree.TopFile.ctl); - while (p.ncol < pardes.MAX_COLS) { + while (p.view().ncol < pardes.MAX_COLS) { // From the widest column's tag, so no column gets too narrow first. p.sync(); var widest: usize = 0; - for (0..p.ncol) |c| if (p.col_w[c] > p.col_w[widest]) { + for (0..p.view().ncol) |c| if (p.view().col_w[c] > p.view().col_w[widest]) { widest = c; }; pardes.tagline.enterHeader(p, widest); @@ -2815,7 +2818,7 @@ test "Term+bash on a pane ctl is Term with its argument, as exec and the tag tak test "a Rename that reaches other files previews them, says so, and is the pane a waiting write answers" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - const id = p.active; + const id = p.view().active; p.fs.lsp_result = null; p.lspRequest(id, .rename, "sum"); Ask.lspResponse(p, p.lsp_ask.wait.?.id, "lib.rs:2:8 sum\nmain.rs:4:13-15 sum\n"); @@ -2862,7 +2865,7 @@ test "Petscii, Palette and Ascii take the state their tag word names, set rather test "a Rename the server answered for this file alone, with other open files saying the name, is previewed and says so" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - p.lspRequest(p.active, .rename, "sum"); + p.lspRequest(p.view().active, .rename, "sum"); Ask.lspResponse(p, p.lsp_ask.wait.?.id, "util.zig:1:8 sum\nmain.zig: also says add, which the server did not rename\n"); try testing.expect(th.logHas(p, "Rename: previewed, not applied: the server renamed in this file only, and 1 other open file(s) say the name")); } @@ -2902,7 +2905,7 @@ test "Lspinfo's answer is the +Lsp pane it fills, as a Rename preview's is its + const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); p.fs.lsp_result = null; - p.lspRequest(p.active, .status, ""); + p.lspRequest(p.view().active, .status, ""); Ask.lspResponse(p, p.lsp_ask.wait.?.id, "language servers:\n"); const shown = p.paneBySerial(p.fs.lsp_result.?).?; try testing.expect(std.mem.endsWith(u8, p.panes[shown].?.file.?.path, "+Lsp")); @@ -2976,10 +2979,10 @@ test "a setting the other frontend has is passed over in the init file, not fail test "the init file saved in a pane applies its settings again, and runs none of its commands twice" { const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .startup_config = "Theme dusk\n", .startup_config_path = "/tmp/pardes-init-test/init" }); defer p.deinit(); - const cols = p.ncol; + const cols = p.view().ncol; pardes.exec.reapplyInitFile(p, "/tmp/pardes-init-test/elsewhere", "Theme acme\n"); try testing.expectEqualStrings("dusk", p.theme().name); pardes.exec.reapplyInitFile(p, "/tmp/pardes-init-test/init", "Theme acme\nNewcol\n"); try testing.expectEqualStrings("acme", p.theme().name); - try testing.expectEqual(cols, p.ncol); + try testing.expectEqual(cols, p.view().ncol); } diff --git a/src/ninep/events.zig b/src/ninep/events.zig index a4094e57..6fd0d345 100644 --- a/src/ninep/events.zig +++ b/src/ninep/events.zig @@ -835,7 +835,7 @@ pub fn writeEvent(p: *Pardes, asked: Req, id: usize) Reply { p.look_missed = false; look.lookAt(p, live, text); p.fs.results_len = 0; - if (!p.look_missed) if (p.panes[p.active]) |found| { + if (!p.look_missed) if (p.panes[p.view().active]) |found| { p.fs.results[0] = found.serial; p.fs.results_len = 1; }; @@ -1334,9 +1334,9 @@ test "an empty range written back is expanded as a click at that point would be" try testing.expectEqual(Status.ok, wr(p, event, "ML1 1\n").reply.status); try testing.expectEqual(pane_files.State.Range{ .q0 = 8, .q1 = 11 }, pane_files.dotOf(pane)); // An exec at 15 runs the word there, `Newcol`. - const cols = p.ncol; + const cols = p.view().ncol; try testing.expectEqual(Status.ok, wr(p, event, "MX15 15\n").reply.status); - try testing.expectEqual(cols + 1, p.ncol); + try testing.expectEqual(cols + 1, p.view().ncol); } test "opens of the log share the open records, and a closed one frees its record" { @@ -1366,13 +1366,13 @@ test "a click in the body reports the offsets of the word it takes, so the recor _ = wr(p, Node.of(scratch, .body), text); for ([_]u32{ serialOf(p), scratch }) |serial| { const id = p.paneBySerial(serial).?; - p.active = p.paneBySerial(if (serial == scratch) serialOf(p) else scratch).?; + p.view().active = p.paneBySerial(if (serial == scratch) serialOf(p) else scratch).?; const event = Node.of(serial, .event); const h = call(p, .{ .tag = 1, .op = .open, .node = event }).reply.handle; var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); _ = try p.render(frame.allocator()); - const rect = p.rects[id]; + const rect = p.view().rects[id]; const x0 = rect.x + config.GUTTER + config.PREFIX_W; const y0 = rect.y + p.panes[id].?.tag_rows; const tab: u16 = config.tab_now; diff --git a/src/ninep/pane.zig b/src/ninep/pane.zig index 3b982803..92d28b99 100644 --- a/src/ninep/pane.zig +++ b/src/ninep/pane.zig @@ -1216,7 +1216,7 @@ test "owned cwd name promotion releases the former directory" { const p = try th.withTerm(testing.allocator); defer p.deinit(); p.newScratchBelow(0); - const id = p.active; + const id = p.view().active; const pane = p.panes[id].?; try pane.setOwnedCwd("/old/directory"); const result = wr(p, Node.of(pane.serial, .name), "saved.txt\n"); diff --git a/src/ninep/screen.zig b/src/ninep/screen.zig index 8d8b6e33..33a8717b 100644 --- a/src/ninep/screen.zig +++ b/src/ninep/screen.zig @@ -220,9 +220,9 @@ test "screen snapshots preserve rendered cells and styles until their handle is const parsed = try std.json.parseFromSlice(std.json.Value, gpa, original, .{}); defer parsed.deinit(); const data = parsed.value.object; - try testing.expectEqual(@as(i64, p.screen_w), data.get("cols").?.integer); - try testing.expectEqual(@as(i64, p.screen_h), data.get("rows").?.integer); - try testing.expectEqual(@as(usize, p.screen_w) * p.screen_h, data.get("cells").?.array.items.len); + try testing.expectEqual(@as(i64, p.view().screen_w), data.get("cols").?.integer); + try testing.expectEqual(@as(i64, p.view().screen_h), data.get("rows").?.integer); + try testing.expectEqual(@as(usize, p.view().screen_w) * p.view().screen_h, data.get("cells").?.array.items.len); try testing.expect(data.get("styles").?.array.items.len > 0); _ = wr(p, Node.of(serialOf(p), .body), "changed\n"); const newer = call(p, .{ .tag = 2, .op = .open, .node = screen_node }); @@ -259,7 +259,7 @@ test "screen inspection leaves the next real frame as it would have been" { 1 => p.update(.{ .command = "New" }), 2 => { p.update(.tick); - try testing.expectEqual(Status.ok, wr(p, Node.of(p.panes[p.active].?.serial, .body), "changed cells\n").reply.status); + try testing.expectEqual(Status.ok, wr(p, Node.of(p.panes[p.view().active].?.serial, .body), "changed cells\n").reply.status); }, 3 => p.update(.{ .command = "Del" }), else => unreachable, diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index 4f155b4f..d15ddd53 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -690,8 +690,8 @@ fn topSize(p: *Pardes, f: TopFile) u64 { .ctl => if (ctl.settingsText(p)) |text| text.len else |_| 0, .commands => if (ctl.commandsText(p)) |text| text.len else |_| 0, .focus => focus: { - if (p.header != null) break :focus 0; - const pn = p.panes[p.active] orelse break :focus 0; + if (p.view().header != null) break :focus 0; + const pn = p.panes[p.view().active] orelse break :focus 0; var digits: [16]u8 = undefined; // unreachable: a u32 serial and a newline fit 16 break :focus (std.fmt.bufPrint(&digits, "{d}\n", .{pn.serial}) catch unreachable).len; @@ -784,7 +784,7 @@ fn readdir(p: *Pardes, req: Req, target: Target) Reply { stageDirent(out, p.gpa, Node.of(serial, .dir), true, name); } }, - .col => for (0..p.ncol) |c| { + .col => for (0..p.view().ncol) |c| { if (skip > 0) { skip -= 1; continue; @@ -841,7 +841,7 @@ fn open(p: *Pardes, req: Req, target: Target) Reply { // Refused, the open's err is the one record of it (the // one rule): no msg besides. p.fs.capturing = true; - panes.newScratchFor(p, p.active, .fs); + panes.newScratchFor(p, p.view().active, .fs); p.fs.capturing = false; p.fs.failure_len = 0; const made = p.panes[slot] orelse return Reply.fail(req.tag, E.NFILE); @@ -1438,7 +1438,7 @@ test "filesystem inspection preserves pending and displayed Look hover" { var frame: std.heap.ArenaAllocator = .init(gpa); defer frame.deinit(); _ = try p.render(frame.allocator()); - const rect = p.rects[0]; + const rect = p.view().rects[0]; p.update(.{ .mouse = .{ .button = .none, .kind = .motion, @@ -1473,13 +1473,13 @@ test "filesystem inspection preserves pending and displayed Look hover" { try testing.expectEqual(Status.ok, answer.reply.status); try testing.expect(std.meta.eql(waiting, p.look_hover_wait)); try testing.expect(std.meta.eql(preview, p.look_hover_preview)); - try testing.expect(p.raw_hover_intent); + try testing.expect(p.view().raw_hover_intent); } } try testing.expectEqual(Status.ok, wr(p, body, "changed").reply.status); try testing.expect(p.look_hover_wait == null); try testing.expect(p.look_hover_preview == null); - try testing.expect(!p.raw_hover_intent); + try testing.expect(!p.view().raw_hover_intent); } test "log stats 0 however much it holds, a stream as acme's generated files are" { @@ -1501,13 +1501,13 @@ test "filesystem pane creation and truncation cancel Look hover" { const p = try withFile(testing.allocator, "word\n"); defer p.deinit(); p.look_hover_wait = .{ .col = 1, .row = 1, .pane = 0, .serial = serialOf(p) }; - p.raw_hover_intent = true; + p.view().raw_hover_intent = true; var req = request; if (req.op == .setattr) req.node = Node.of(serialOf(p), .body); try testing.expectEqual(Status.ok, call(p, req).reply.status); try testing.expect(p.look_hover_wait == null); try testing.expect(p.look_hover_preview == null); - try testing.expect(!p.raw_hover_intent); + try testing.expect(!p.view().raw_hover_intent); } } @@ -1839,9 +1839,9 @@ test "random placements, refused or not, leave no pane under its tag and two row 6 => _ = th.wr(p, Node.of(at, .exec), "Delcol\n"), else => _ = th.wr(p, Node.of(at, .ctl), "delete\n"), } - for (0..p.ncol) |c| if (!layout.columnAtMinimums(p, c)) { + for (0..p.view().ncol) |c| if (!layout.columnAtMinimums(p, c)) { std.debug.print("seed {d} rows {d} step {d} action {d}: column {d} under its minimums\n", .{ seed, rows, step, action, c }); - for (p.cols[c].panes[0..p.cols[c].n]) |id| std.debug.print(" pane {d} h {d} min {d}\n", .{ id, p.rects[id].h, layout.minRows(p, id) }); + for (p.view().cols[c].panes[0..p.view().cols[c].n]) |id| std.debug.print(" pane {d} h {d} min {d}\n", .{ id, p.view().rects[id].h, layout.minRows(p, id) }); return error.TestUnexpectedResult; }; } @@ -1997,14 +1997,14 @@ test "look and exec read back what their own open's write touched; a fresh open const mine = call(p, .{ .tag = 1, .op = .open, .node = exec, .omode = 2 }).reply.handle; const theirs = call(p, .{ .tag = 2, .op = .open, .node = exec, .omode = 2 }).reply.handle; _ = call(p, .{ .tag = 3, .op = .write, .node = exec, .handle = mine, .data = "Term\n" }); - const made = p.panes[p.active].?.serial; + const made = p.panes[p.view().active].?.serial; try testing.expect(made != first); _ = call(p, .{ .tag = 4, .op = .write, .node = exec, .handle = theirs, .data = "Msg hi\n" }); var want: [16]u8 = undefined; // Read at the offset the write left, as a shell's `exec 3<>` does. try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{made}), call(p, .{ .tag = 5, .op = .read, .node = exec, .handle = mine, .off = 4, .size = 64 }).bytes); try testing.expectEqualStrings("", call(p, .{ .tag = 6, .op = .read, .node = exec, .handle = mine, .off = 4, .size = 64 }).bytes); - const said = p.panes[p.active].?.serial; + const said = p.panes[p.view().active].?.serial; try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{said}), call(p, .{ .tag = 7, .op = .read, .node = exec, .handle = theirs, .size = 64 }).bytes); const fresh = call(p, .{ .tag = 8, .op = .open, .node = exec }).reply.handle; try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "{d}\n", .{said}), call(p, .{ .tag = 9, .op = .read, .node = exec, .handle = fresh, .size = 64 }).bytes); @@ -2061,9 +2061,9 @@ test "no placement leaves a pane shorter than its tag and two rows; a full colum var count: usize = 0; for (p.panes) |slot| count += @intFromBool(slot != null); try testing.expectEqual(made, count); // the refused one is gone - for (0..p.ncol) |c| for (p.cols[c].panes[0..p.cols[c].n]) |k| { - if (p.cols[c].n > 1 and !p.panes[k].?.collapsed) - try testing.expect(p.rects[k].h >= p.panes[k].?.tag_rows + pardes.layout.min_body_rows); + for (0..p.view().ncol) |c| for (p.view().cols[c].panes[0..p.view().cols[c].n]) |k| { + if (p.view().cols[c].n > 1 and !p.panes[k].?.collapsed) + try testing.expect(p.view().rects[k].h >= p.panes[k].?.tag_rows + pardes.layout.min_body_rows); }; } @@ -2111,6 +2111,6 @@ test "a pane made from pane/new goes last in its column, even when the last pane for (0..3) |_| { const made = call(p, .{ .tag = 1, .op = .open, .node = @backingInt(TopFile.new) }).reply.handle; p.sync(); - try testing.expectEqual(made, p.panes[p.cols[0].panes[p.cols[0].n - 1]].?.serial); + try testing.expectEqual(made, p.panes[p.view().cols[0].panes[p.view().cols[0].n - 1]].?.serial); } } -- cgit v1.3