diff options
Diffstat (limited to 'src/gui')
| -rw-r--r-- | src/gui/gui.zig | 132 |
1 files changed, 66 insertions, 66 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig index eb8636be..85245b54 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -473,20 +473,20 @@ test "the shader instance ABI: the flags after the colours, the clip after them" } fn updateCoreResize(core: *pardes.Pardes, cols: u16, rows: u16, cell_w: u32, cell_h: u32, tag_w: u32, tag_h: u32) bool { - core.update(resizeOf(core, cols, rows, cell_w, cell_h, tag_w, tag_h) orelse return false); + core.update(resizeOf(core.view(), cols, rows, cell_w, cell_h, tag_w, tag_h) orelse return false); return true; } /// The resize a window of `cols` by `rows` cells of these sizes is to the /// live view, or null when it is that already. -fn resizeOf(core: anytype, cols: u16, rows: u16, cell_w: u32, cell_h: u32, tag_w: u32, tag_h: u32) ?pardes.Event { +fn resizeOf(v: *const pardes.Pardes.View, cols: u16, rows: u16, cell_w: u32, cell_h: u32, tag_w: u32, tag_h: u32) ?pardes.Event { const metrics: pardes.RowMetrics = .{ .body_w = @intCast(cell_w), .body_h = @intCast(cell_h), .tagline_w = @intCast(tag_w), .tagline_h = @intCast(tag_h) }; - const same_metrics = std.meta.eql(metrics, core.row_metrics); + const same_metrics = std.meta.eql(metrics, v.row_metrics); if (comptime pardes.pdf_enabled) { const cell_px_w: u16 = @intCast(@min(@max(1, cell_w), std.math.maxInt(u16))); const cell_px_h: u16 = @intCast(@min(@max(1, cell_h), std.math.maxInt(u16))); - if (cols == core.screen_w and rows == core.screen_h and - cell_px_w == core.cell_pixels.w and cell_px_h == core.cell_pixels.h and same_metrics) return null; + if (cols == v.screen_w and rows == v.screen_h and + cell_px_w == v.cell_pixels.w and cell_px_h == v.cell_pixels.h and same_metrics) return null; return .{ .resize = .{ .cols = cols, .rows = rows, @@ -494,7 +494,7 @@ fn resizeOf(core: anytype, cols: u16, rows: u16, cell_w: u32, cell_h: u32, tag_w .row_metrics = metrics, } }; } - if (cols == core.screen_w and rows == core.screen_h and same_metrics) return null; + if (cols == v.screen_w and rows == v.screen_h and same_metrics) return null; return .{ .resize = .{ .cols = cols, .rows = rows, .row_metrics = metrics } }; } @@ -824,7 +824,7 @@ test "GUI completion failure survives backlog and leaves the document unchanged" defer core.deinit(); const pane = try core.setTestFile("abc"); pane.body.cur_col = 1; - core.lspRequest(core.active, .completion, ""); + core.lspRequest(core.view().active, .completion, ""); const id = core.lsp_ask.wait.?.id; var queue: Queue = .{ .io = std.testing.io, .gpa = gpa, .lsp_allocator = gpa, .lsp_id = id }; defer queue.deinit(); @@ -898,11 +898,11 @@ test "GUI worker setup failures finish matching LSP and pipe requests" { }; defer queue.deinit(); var tasks: PipeTasks = .{}; - core.lspRequest(core.active, .status, ""); + core.lspRequest(core.view().active, .status, ""); const req: host_io.Lsp.Request = .{ .id = core.lsp_ask.wait.?.id, .kind = .status, - .pane = @intCast(core.active), + .pane = @intCast(core.view().active), .offset = 0, .arg = "", }; @@ -1766,9 +1766,9 @@ fn localSession( defer core.deinit(); g.hit_core = core; defer g.hit_core = null; - core.frontend.windowed = true; - core.frontend.native_images = true; - core.frontend.native_image_patches = true; + core.view().frontend.windowed = true; + core.view().frontend.native_images = true; + core.view().frontend.native_image_patches = true; observeGuiFont(g, core); syncTaglineFont(g, core); @@ -1904,11 +1904,11 @@ fn localSession( shell.stopPtys(); clearNativeImages(g); g.prepared_images.clearRetainingCapacity(); - nc.frontend.native_images = true; - nc.frontend.native_image_patches = true; + nc.view().frontend.native_images = true; + nc.view().frontend.native_image_patches = true; nc.host = host; if (fs) |f| f.reset(nc); - nc.frontend.windowed = true; + nc.view().frontend.windowed = true; core.deinit(); core = nc; frame_probe = &nc.frames; // the old core's ring went with it @@ -2055,7 +2055,7 @@ const OwnView = struct { const g = v.g; if (fitTaglineFont(g, core.settings.font.tagline_percent)) v.s.remote.?.link.dirty = true; const geom = windowCells(g); - if (resizeOf(core, geom.cols, geom.rows, g.cell_w, g.cell_h, g.tagline_width, g.tagline_height)) |ev| v.in.post(ev); + if (resizeOf(core.view(), geom.cols, geom.rows, g.cell_w, g.cell_h, g.tagline_width, g.tagline_height)) |ev| v.in.post(ev); if (v.pointer) refreshPresentedPointer(g, v.in); runDemo(g, v.in, core); if (v.s.test_mode) { @@ -2565,7 +2565,7 @@ const Input = struct { if (in.remote) |r| return r.post(ev); // The window's input is its own view's, a replica client's input // the session's last or not. - if (in.shell) |s| if (s.core.view != s.gview) { + if (in.shell) |s| if (s.core.live != s.gview) { _ = s.windowView(); }; in.core.update(ev); @@ -2578,7 +2578,7 @@ const Input = struct { return; } if (in.shell) |s| { - if (s.windowsOpen() > 1) return s.closeView(s.core.view); + if (s.windowsOpen() > 1) return s.closeView(s.core.live); // The last window, with replica clients: they keep the session, // as a Detach would, the daemon holding it. if (s.peers.count() > 0 and daemon.kept()) return s.closeTheWindow(); @@ -2883,7 +2883,7 @@ fn gridCellAtDimensions( // On the rule over this row, which is where two panes meet if they do. point.rule_above = row > 0 and @max(y, 0) - @as(f32, @floatFromInt(row)) * @max(body_h, 1) < dp(rule_grab_px); if (onGrid(core, x / @max(body_w, 1), y / @max(body_h, 1))) for (core.surface.tagLayers()) |*layer| { - if (layer.tagHit(x, y, body_w, body_h, tagline_w, @floatFromInt(core.row_metrics.tagline_h))) |hit| { + if (layer.tagHit(x, y, body_w, body_h, tagline_w, @floatFromInt(core.view().row_metrics.tagline_h))) |hit| { point.tag_hit = hit; break; } @@ -2894,7 +2894,7 @@ fn gridCellAtDimensions( /// Whether a point, in cells, is on the grid. fn onGrid(core: *const pardes.Pardes, x: f32, y: f32) bool { return std.math.isFinite(x) and std.math.isFinite(y) and x >= 0 and y >= 0 and - x < @as(f32, @floatFromInt(core.screen_w)) and y < @as(f32, @floatFromInt(core.screen_h)); + x < @as(f32, @floatFromInt(core.view().screen_w)) and y < @as(f32, @floatFromInt(core.view().screen_h)); } fn gridCellAtPixels(g: *const Gui, core: *const pardes.Pardes, x: f32, y: f32) MouseCell { @@ -2913,12 +2913,12 @@ test "tagline pointer mapping retains physical grips and carries logical text co defer core.deinit(); core.update(.{ .resize = .{ .cols = 60, .rows = 12 } }); core.update(.{ .command = "Newcol" }); - core.row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 12 }; + core.view().row_metrics = .{ .body_w = 10, .body_h = 20, .tagline_w = 8, .tagline_h = 12 }; var arena = std.heap.ArenaAllocator.init(std.testing.allocator); defer arena.deinit(); _ = try core.render(arena.allocator()); - const r = core.rects[core.active]; + const r = core.view().rects[core.view().active]; const body_w: f32 = 10; const body_h: f32 = 20; const tag_w: f32 = 8; @@ -2934,7 +2934,7 @@ test "tagline pointer mapping retains physical grips and carries logical text co try std.testing.expect(grip.tag_hit == null); try std.testing.expectEqual(r.x + config.GUTTER - 1, grip.col); - const body_y = tag_y + core.panes[core.active].?.tag_rows; // a long tag wraps + const body_y = tag_y + core.panes[core.view().active].?.tag_rows; // a long tag wraps const body = gridCellAtDimensions(core, x, (@as(f32, @floatFromInt(body_y)) + 0.5) * body_h, body_w, body_h, tag_w); try std.testing.expectEqual(pixelCell(x, 10), body.col); try std.testing.expectEqual(body_y, body.row); @@ -2968,7 +2968,7 @@ fn wheelAt(g: *Gui, in: *Input, w: WheelTurn, mc: MouseCell) void { const core = in.core; const hit: ?usize = for (core.panes, 0..) |slot, i| { if (slot == null) continue; - const r = core.rects[i]; + const r = core.view().rects[i]; if (mc.col >= r.x and mc.col < r.x + r.w and mc.row >= r.y and mc.row < r.y + r.h) break i; } else null; if (g.scroll_pane) |old| if (hit == null or hit.? != old) { @@ -2976,7 +2976,7 @@ fn wheelAt(g: *Gui, in: *Input, w: WheelTurn, mc: MouseCell) void { }; if (hit) |id| { const pdf_target = if (comptime pardes.pdf_enabled) - core.frontend.native_images and core.panes[id].?.pdfPage() != null + core.view().frontend.native_images and core.panes[id].?.pdfPage() != null else false; const pane = core.panes[id].?; @@ -3259,11 +3259,11 @@ const Shell = struct { fn detachWindow(ctx: ?*anyopaque) void { const s = shellOf(ctx); // A replica client's: its link ends. - if (s.peers.detach(s.core.view)) return; - if (s.gui == null) return s.core.reportFailure(s.core.active, "Detach: no window is open"); + if (s.peers.detach(s.core.live)) return; + if (s.gui == null) return s.core.reportFailure(s.core.view().active, "Detach: no window is open"); // One of several: its window goes, and the session stays in the rest. - if (s.windowsOpen() > 1) return s.closeView(s.core.view); - if (!daemon.kept()) return s.core.reportFailure(s.core.active, "Detach: no pardes daemon keeps this session; closing its window ends it"); + if (s.windowsOpen() > 1) return s.closeView(s.core.live); + if (!daemon.kept()) return s.core.reportFailure(s.core.view().active, "Detach: no pardes daemon keeps this session; closing its window ends it"); s.closeTheWindow(); } @@ -3276,7 +3276,7 @@ const Shell = struct { /// The Gui holds the window of the core's live view. fn follow(s: *Shell) void { const g = s.gui orelse return; - const k = s.core.view; + const k = s.core.live; if (s.gview == k) return; // A replica client's view has no window here: the Gui keeps the one // it holds (`windowView` puts that view back when it acts). @@ -3338,7 +3338,7 @@ const Shell = struct { /// (its size, its scroll): a replica client's input may have been the /// last. True when it was not, and is now. fn windowView(s: *Shell) bool { - if (s.core.view == s.gview or !pardes.views.isOpen(s.core, s.gview)) return false; + if (s.core.live == s.gview or !pardes.views.isOpen(s.core, s.gview)) return false; s.core.toView(s.gview); return true; } @@ -3355,7 +3355,7 @@ const Shell = struct { s.core.closeView(k); // Into another window's view, if a client's was the one left live. for (0..pardes.views.max) |i| if (s.windowed & (@as(u8, 1) << @intCast(i)) != 0 and pardes.views.isOpen(s.core, @intCast(i))) { - if (s.core.view != i) s.core.toView(@intCast(i)); + if (s.core.live != i) s.core.toView(@intCast(i)); break; }; s.follow(); @@ -3507,7 +3507,7 @@ const Shell = struct { /// live view's, the others open as `--attach` opens one; a replica /// client's, kept for its rejoin (views.away), none. fn resumeWindows(s: *Shell) void { - const live = s.core.view; + const live = s.core.live; s.gview = live; for (0..pardes.views.max) |i| { const k: u8 = @intCast(i); @@ -3608,7 +3608,7 @@ const Shell = struct { }, .lsp_status => |text| { var mbuf: [256]u8 = undefined; - s.core.setStatus(s.core.active, message.stamp(&mbuf, "lsp", text)); + s.core.setStatus(s.core.view().active, message.stamp(&mbuf, "lsp", text)); s.lsp_allocator.free(text); }, .pipe => |response_value| { @@ -3855,12 +3855,11 @@ fn pollFrame(ctx: ?*anyopaque) void { }; // A replica client's view live: the window's own view back before what // the window does to it (its size, its scroll, its font). - if (core.view != s.gview) { + if (core.live != s.gview) { const geom = windowCells(g); - const own = if (core.parked[s.gview]) |slot| &slot.view else null; const due = g.scroll_pane != null or g.scroll_notch != 0 or g.glide.moving() or core.settings.font.tagline_percent != g.tagline_percent or core.settings.font.pending or - (own != null and resizeOf(own.?, geom.cols, geom.rows, g.cell_w, g.cell_h, g.tagline_width, g.tagline_height) != null); + (if (core.views[s.gview]) |*own| resizeOf(own, geom.cols, geom.rows, g.cell_w, g.cell_h, g.tagline_width, g.tagline_height) != null else false); if (due) _ = s.windowView(); } syncWindowOpacity(g, core); @@ -3939,6 +3938,7 @@ fn demoDue(g: *const Gui) ?c_int { /// focused pane's body; its clock starts at the first loop. Its end /// ends the session (PARDES_FRAMES has the timings then). fn runDemo(g: *Gui, in: *Input, core: *pardes.Pardes) void { + const v = core.view(); const steps = g.demo; var next = g.demo_next orelse return; const now = monoNs(); @@ -3949,7 +3949,7 @@ fn runDemo(g: *Gui, in: *Input, core: *pardes.Pardes) void { } defer g.demo_next = next; while (next < steps.len and g.demo_start_ns + @as(u64, steps[next].at_ms) * std.time.ns_per_ms <= now) : (next += 1) { - const r = core.rects[core.active]; + const r = v.rects[v.active]; if (steps[next].act != .phase) g.input_seen = true; switch (steps[next].act) { .wheel => |notches| { @@ -3967,7 +3967,7 @@ fn runDemo(g: *Gui, in: *Input, core: *pardes.Pardes) void { .phase => {}, .click => |click| { core.frames.input(now); - const pane = core.panes[core.active] orelse continue; + const pane = core.panes[v.active] orelse continue; const top = core.bodyTop(pane, r); const row: u16 = top + @as(u16, @intFromFloat(click.at * @as(f32, @floatFromInt(r.h -| pane.tag_rows -| 1)))); const col: u16 = if (click.rail) r.x else r.x + config.GUTTER + 4; @@ -3987,10 +3987,10 @@ fn runDemo(g: *Gui, in: *Input, core: *pardes.Pardes) void { for (core.panes) |slot| if (slot) |pane| { newest = @max(newest, pane.serial); }; - _ = pardes.exec.executeFrom(core, core.active, line, false); + _ = pardes.exec.executeFrom(core, v.active, line, false); // What it opened is what the next steps scroll. for (core.panes, 0..) |slot, id| if (slot) |pane| if (pane.serial > newest) { - core.active = id; + v.active = id; core.needs_frame = true; }; }, @@ -4135,7 +4135,7 @@ fn postPresent(ctx: ?*anyopaque) void { if (!s.presented) return; // A client's view live: the window's frame counts when its own view is // live and drawn. - if (s.core.view != s.gview) return; + if (s.core.live != s.gview) return; var in: Input = .{ .core = s.core }; refreshPresentedPointer(g, &in); s.core.presented(); @@ -4156,7 +4156,7 @@ fn spawnPane(ctx: ?*anyopaque, pane: u8, cwd: []const u8) void { // The new shell starts before a running one goes: one that cannot // start leaves the running one be (pty/ctl's exec). const running = s.ptys[pane] != null; - const child = host_io.forkShell(s.core, pane, s.prompt_rcs, s.core.shellBin(), cwd, s.core.screen_h, s.core.screen_w) catch |err| { + const child = host_io.forkShell(s.core, pane, s.prompt_rcs, s.core.shellBin(), cwd, s.core.view().screen_h, s.core.view().screen_w) catch |err| { if (running) return s.core.restartFailed(pane, err); return s.core.shellFailed(pane, err); }; @@ -4363,7 +4363,7 @@ fn pipe(ctx: ?*anyopaque, id: u32) void { const s = shellOf(ctx); if (s.threads_ok) return selection_pipe.start(s.io, s.gpa, s.core, s.pipe_tasks, id, s.queue, Queue.pushPipe); s.core.update(.{ .pipe_resp = .{ .id = id, .success = false, .outputs = &.{} } }); - s.core.reportError(s.core.active, "pipe", error.WorkersUnavailable); + s.core.reportError(s.core.view().active, "pipe", error.WorkersUnavailable); } fn kindJob(ctx: ?*anyopaque, pane: u8, serial: u32, token: u32) void { @@ -4545,7 +4545,7 @@ test "a click over codex in a terminal reaches its pty with its modifiers; Shift }.f; _ = try take(core, &sent); const pane = core.panes[0].?; - const r = core.rects[0]; + const r = core.view().rects[0]; const mc: MouseCell = .{ .col = r.x + config.GUTTER + 5, .row = core.bodyTop(pane, r) + 3 }; const next: MouseCell = .{ .col = mc.col + 1, .row = mc.row }; core.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?1049h\x1b[?1000h\x1b[?1002h\x1b[?1003h\x1b[?1006h" } }); @@ -4594,7 +4594,7 @@ test "a wheel over codex in a terminal reaches its pty as the mouse reports it a }; _ = try Sent.take(core, &sent); const pane = core.panes[0].?; - const r = core.rects[0]; + const r = core.view().rects[0]; const mc: MouseCell = .{ .col = r.x + config.GUTTER + 5, .row = core.bodyTop(pane, r) + 3 }; // What codex 0.159's chat sets on start. core.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?2004h\x1b[>7u\x1b[?1004h\x1b[?1049h\x1b[?1007l\x1b[?1000h\x1b[?1002h\x1b[?1003h\x1b[?1006h" } }); @@ -4650,7 +4650,7 @@ fn stepGlide(g: *Gui, core: *pardes.Pardes, gpa: std.mem.Allocator) void { resetScroll(g); break :wheel; }; - const r = core.rects[id]; + const r = core.view().rects[id]; if (r.h <= pane.tag_rows or r.w <= config.GUTTER) { resetScroll(g); break :wheel; @@ -4706,11 +4706,11 @@ test "a notch scrolls the core at once and the picture glides after it, a wrappe var s = try core.render(arena.allocator()); var g = testGui(10, 20, 6, 12); defer g.glide.deinit(gpa); - const r = core.rects[core.active]; - g.scroll_pane = core.active; + const r = core.view().rects[core.view().active]; + g.scroll_pane = core.view().active; g.scroll_col = r.x + 10; g.scroll_row = r.y + r.h - 2; - const body_y = core.bodyTop(core.panes[core.active].?, r); + const body_y = core.bodyTop(core.panes[core.view().active].?, r); const row_before = try gpa.dupe(pardes.Cell, s.cells[@as(usize, body_y + 1) * s.cols + r.x + config.GUTTER ..][0 .. r.w - config.GUTTER]); defer gpa.free(row_before); // The window has drawn the view once (Glide.frame finds a view that moved). @@ -4718,9 +4718,9 @@ test "a notch scrolls the core at once and the picture glides after it, a wrappe glideFrame(&g, gpa, s); // One notch down: the core is a line on at once. g.scroll_notch = 1; - const scrolled = core.panes[core.active].?.scroll(); + const scrolled = core.panes[core.view().active].?.scroll(); stepGlide(&g, core, gpa); - try std.testing.expectEqual(scrolled + 1, core.panes[core.active].?.scroll()); + try std.testing.expectEqual(scrolled + 1, core.panes[core.view().active].?.scroll()); _ = arena.reset(.retain_capacity); s = try core.render(arena.allocator()); glideFrame(&g, gpa, s); @@ -4768,8 +4768,8 @@ test "a wheel's caret rides with its line, the text's own glide, never a spring var s = try core.render(arena.allocator()); var g = testGui(10, 20, 6, 12); defer g.glide.deinit(gpa); - const r = core.rects[core.active]; - g.scroll_pane = core.active; + const r = core.view().rects[core.view().active]; + g.scroll_pane = core.view().active; g.scroll_col = r.x + 10; g.scroll_row = r.y + r.h - 2; stepGlide(&g, core, gpa); @@ -4828,7 +4828,7 @@ const GlideRun = struct { glideFrame(g, gpa, s); seeCaret(g, s, fixedCellLayout(g), @floatFromInt(@as(u32, s.rows) * g.cell_h), now); seq.offsets[frame] = g.glide.follow.offset; - seq.lines[frame] = @intCast(core.panes[core.active].?.file.?.scroll); + seq.lines[frame] = @intCast(core.panes[core.view().active].?.file.?.scroll); seq.carets[frame] = caretRow(g, s, now) orelse -1; seq.cells[frame] = if (s.cursor) |cu| @floatFromInt(cu.y) else -1; } @@ -4873,7 +4873,7 @@ test "every scroll glides on one law: a half page, a page, the far jumps, a run _ = try core.render(arena.allocator()); var g = testGui(10, 20, 6, 12); defer g.glide.deinit(gpa); - const body_h: f32 = @floatFromInt(core.rects[core.active].h - core.panes[core.active].?.tag_rows); + const body_h: f32 = @floatFromInt(core.view().rects[core.view().active].h - core.panes[core.view().active].?.tag_rows); const ctrl = struct { fn key(cp: u21) pardes.Key { return .{ .cp = cp, .ctrl = true }; @@ -4996,7 +4996,7 @@ fn stepScroll(g: *Gui, core: *pardes.Pardes, gpa: std.mem.Allocator) void { if (g.scroll_lag == 0 and g.scroll_notch == 0 and !g.glide.moving()) resetScroll(g); return; } - const r = core.rects[id]; + const r = core.view().rects[id]; if (r.h <= pane.tag_rows) { resetScroll(g); return; @@ -5494,7 +5494,7 @@ fn renderFrame( g.cursor_quad_alpha = if (quad_mode) caret_alpha * blink_alpha else 0; // The probe's view of this frame's motion (FrameStats.Frame). // A focused PDF's strip is the core's (pdf_view.draw). - const pdf_focus = if (core.panes[core.active]) |pane| pane.hasPdf() else false; + const pdf_focus = if (core.panes[core.view().active]) |pane| pane.hasPdf() else false; if (!pdf_focus) core.frames.scroll = g.glide.follow.offset; core.frames.caret = caretRow(g, surface, now) orelse 0; const cursors_shown = !quad_mode; @@ -5812,7 +5812,7 @@ test "the layer cover is the per-cell layer scan, over a core's layouts and rand var notices = false; for (0..32) |step| { if (step & 3 == 0) try std.testing.expect(core.executeBuiltinLine(2, "Collapse")); - core.prefix = if (step & 4 != 0) .leader else .none; + core.view().prefix = if (step & 4 != 0) .leader else .none; if (step & 8 != 0) { try std.testing.expect(core.executeBuiltinLine(0, "Msg a message chip over the body")); try std.testing.expect(core.executeBuiltinLine(3, "Msg another")); @@ -5830,7 +5830,7 @@ test "the layer cover is the per-cell layer scan, over a core's layouts and rand const cell = cover[@as(usize, region.rect.y) * s.cols + region.rect.x + offset]; try std.testing.expect(cell.grip); try std.testing.expectEqual(offset, cell.grip_offset); - try std.testing.expectEqual(region.owner == core.active, cell.focus); + try std.testing.expectEqual(region.owner == core.view().active, cell.focus); } } for (s.tagLayers()) |layer| notices = notices or (layer.rows != 0 and layer.kind == .notice); @@ -6151,7 +6151,7 @@ test "every pixel of a grip column is band, button or ring, and the button sits pane.tag.own = try gpa.dupe(u8, "second\nthird"); core.newScratchBelow(0); for ([_]struct { w: u32, h: u32, tag: u32 }{ .{ .w = 10, .h = 20, .tag = 12 }, .{ .w = 17, .h = 35, .tag = 30 }, .{ .w = 9, .h = 19, .tag = 15 }, .{ .w = 12, .h = 24, .tag = 24 } }) |m| for ([_]usize{ 0, 1 }) |focus| for ([_]bool{ false, true }) |dirty| { - core.active = focus; + core.view().active = focus; pane.file.?.revision = pane.file.?.saved_revision + @intFromBool(dirty); core.sync(); const s = try core.render(core.scratch.allocator()); @@ -7915,7 +7915,7 @@ test "the scrollbar thumb moves by the pixel and follows a glide" { const at11 = try thumb.top(&g, core); // A line of a thousand moves it a fraction of a row, not 0 or 20 px. try std.testing.expect(at11 > at10 and at11 - at10 < 1); - g.glide.pane = core.active; + g.glide.pane = core.view().active; g.glide.follow.offset = -1; try std.testing.expectApproxEqAbs(at10, try thumb.top(&g, core), 1e-3); // A wrapped line: the picture moved two rows for the one line, and the @@ -7965,8 +7965,8 @@ test "an empty column is ruled on both sides, as between two filled ones" { // Newcol from the left pane: an empty column between the two filled ones. pardes.layout.newColumn(core, 0); core.sync(); - try std.testing.expectEqual(@as(usize, 3), core.ncol); - try std.testing.expectEqual(@as(usize, 0), core.cols[1].n); + try std.testing.expectEqual(@as(usize, 3), core.view().ncol); + try std.testing.expectEqual(@as(usize, 0), core.view().cols[1].n); const s = try core.render(core.scratch.allocator()); var g = testGui(10, 20, 6, 12); defer g.decor.deinit(gpa); @@ -7977,7 +7977,7 @@ test "an empty column is ruled on both sides, as between two filled ones" { // Its left edge and its right edge (the next column's left): each a // rule `rule_px` wide in the border colour, down to the window's foot. for ([_]usize{ 1, 2 }) |column| { - const px: f32 = @floatFromInt(@as(u32, core.col_x[column]) * 10); + const px: f32 = @floatFromInt(@as(u32, core.view().col_x[column]) * 10); const rule = for (g.decor.items) |item| { if (@abs(item.x0 - (px / 800 * 2 - 1)) < 1e-4 and @abs(item.x1 - ((px + @as(f32, @floatFromInt(s.chrome.rule_px))) / 800 * 2 - 1)) < 1e-4 and std.mem.eql(f32, &.{ item.br, item.bg, item.bb }, &border)) break item; @@ -8070,7 +8070,7 @@ test "decor is read from the regions" { try buildDecor(&g, gpa, s, &groups, layout, 800, 480, true); // A spine one pixel wide at each column's left edge, down from under the // workspace tag; a rail two pixels wide at each pane's. - for (core.col_x[0..core.ncol]) |x| { + for (core.view().col_x[0..core.view().ncol]) |x| { const left = ndc.x(@as(f32, @floatFromInt(x)) * 10); // Two pixels (rule_px), and none at the window's own edge. const spine = for (g.decor.items) |item| { |
