diff options
Diffstat (limited to 'core/replica.zig')
| -rw-r--r-- | core/replica.zig | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/core/replica.zig b/core/replica.zig index 993c1f09..31a06214 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -1230,20 +1230,14 @@ pub const Replica = struct { /// Its own view drawn and presented through `present`, between steps /// (views.drawOne): nothing the digest covers moves. The epoch's trees /// held while a copy is (a render can make or drop a syntax tree). - pub fn draw(r: *Replica, present: pardes.views.Present) void { + pub fn draw(r: *Replica, present: pardes.views.Present) bool { rollback.Epoch.select(&r.epoch); defer rollback.Epoch.select(null); - pardes.views.drawOne(r.core(), r.view, present) catch {}; - } - - /// `f(ctx, core)` with its own view live, outside any step, as `draw` - /// draws it (views.within): what its frontend reads of its own view - /// (its pointer's cells, its size) while another client's input was the - /// session's last. - pub fn within(r: *Replica, ctx: anytype, comptime f: fn (@TypeOf(ctx), *Pardes) anyerror!void) void { - rollback.Epoch.select(&r.epoch); - defer rollback.Epoch.select(null); - pardes.views.within(r.core(), r.view, ctx, f) catch {}; + // A frame drawing owes another is this process's, not the core's. + const c = r.core(); + const needs = c.needs_frame; + defer c.needs_frame = needs; + return pardes.views.drawOne(c, r.view, present) catch true; } /// One of the authority's terminal messages (`Screens.flush`, or an @@ -4180,14 +4174,14 @@ test "a replica joined from a themed dump paints its taglines in the restored th try std.testing.expectEqualStrings("rose_pine_moon", r.core().theme().name); try std.testing.expectEqual(expected.tag_bg, r.core().chromeTheme().tag_bg); try std.testing.expectEqual(expected.tag_fg, r.core().chromeTheme().tag_fg); - r.draw(.{ .ctx = null, .f = null }); + _ = r.draw(.{ .ctx = null, .f = null }); try std.testing.expectEqual(expected.tag_bg, r.core().surface.chrome.tag_bg); try std.testing.expectEqual(expected.tag_fg, r.core().surface.chrome.tag_fg); try std.testing.expectEqual(digestOf(a), r.digest()); // A later theme is an ordinary confirmed unit, its chrome set at once. r.confirm(try a.local(.{ .command = "Theme monokai_pro_classic" })); r.settle(); - r.draw(.{ .ctx = null, .f = null }); + _ = r.draw(.{ .ctx = null, .f = null }); const changed = pardes.colors.ChromeTheme.fromTheme(a.core.theme()); try std.testing.expectEqual(changed.tag_bg, r.core().surface.chrome.tag_bg); try std.testing.expectEqual(changed.tag_fg, r.core().surface.chrome.tag_fg); @@ -4962,9 +4956,10 @@ test "a closed terminal with a kitty image brought back on a client: its image d r.confirm(try a.local(.{ .focus = true })); const Seen = struct { px: ?[4]u8 = null, - fn take(ctx: ?*anyopaque, s: *const pardes.Surface) void { + fn take(ctx: ?*anyopaque, s: *const pardes.Surface) bool { const seen: *@This() = @ptrCast(@alignCast(ctx.?)); for (s.placements.items) |pl| seen.px = pl.raster.bytes()[0..4].*; + return true; } }; var sent: std.ArrayListUnmanaged([]u8) = .empty; @@ -4976,13 +4971,13 @@ test "a closed terminal with a kitty image brought back on a client: its image d try key(r, 'o', &sent); try std.testing.expect(r.copy.held); var seen: Seen = .{}; - r.draw(.{ .ctx = &seen, .f = Seen.take }); + _ = r.draw(.{ .ctx = &seen, .f = Seen.take }); try std.testing.expectEqual([4]u8{ 0x11, 0x22, 0x33, 0xff }, seen.px.?); // The session's own key first: back to the copy, the key applied again. r.confirm(try a.local(.{ .key = .{ .cp = 'l', .text = "l" } })); r.settle(); seen = .{}; - r.draw(.{ .ctx = &seen, .f = Seen.take }); + _ = r.draw(.{ .ctx = &seen, .f = Seen.take }); try std.testing.expectEqual([4]u8{ 0x11, 0x22, 0x33, 0xff }, seen.px.?); r.confirm(try a.take(sent.items[0])); r.settle(); |
