summaryrefslogtreecommitdiff
path: root/core/views.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-18 23:31:53 -0300
committerGabriel Schneider <[email protected]>2026-11-19 07:26:38 -0300
commit2d30f3781ab40c38710835806a1029359509d27b (patch)
tree282b4cee975ee2d74a53691acd99cfc03d55ef89 /core/views.zig
parent5e162e2e8b208367720b8be8de3bfe51b010aa68 (diff)
downloadpardes-2d30f3781ab40c38710835806a1029359509d27b.tar.gz
pardes-2d30f3781ab40c38710835806a1029359509d27b.zip
frontends: the terminal and the window draw and turn input into events from the frame and one record beside it (the reorganisation's runners, step 10a, on the line as it is now): surface.Facts, the core's (Pardes.facts) and pointed at by the frame it is filled for (Surface.facts), filled by draw.place in the walk over the panes it makes anyway and by a runner after an input it applied (draw.facts), carries what a frontend took from the core (the view's size, cell pixels and row metrics, each open pane's rectangle, tag rows, context rows, serial, whether a terminal whose program takes the wheel or a kind's, its mode, the jumps' back and forward, the settings it draws by); the window keeps a copy (Gui.facts) with the frame it shows (Gui.frame) and its hit tests, wheel, touchpad rows, timedemo, blink, overlays and dim read only those; Host.present returns whether the frame was shown, so present_skipped leaves the core and nothing writes it; the frame statistics are the runner's (Options.frames, Pardes.frames a pointer to them), which the frontends write and the core's draw reads; Replica.draw returns the shown and keeps needs_frame itself, so the two client loops put nothing back; OwnView and Replica.within are deleted (the window client's own pass reads its facts, its inputs fed after each event as before); rollback-bench compiles again; the tape's watched fields lose present_skipped and present answers a bool, so the semantics word moves (0900e560fd6395ef, pardes-seam-b's, -> 2f615168fe07b35f). The first version (psvoxrup, on pardes-tree) kept the record by value in every Surface, and every Surface a tag line builds for a moment copied its 1.3 KB more: +1,556 instructions an image-frame, +3,763 a render (perf record: memcpy); now perfops against tree1 97 counts within 0.1%, largest image-frame +0.029%. Brought onto pardes-seam-b: the client set-up keeps the Distrusted list beside the runner's frame statistics, Options' local fields both, and the rollback test's present answers a bool. Gate: frames 77/77 byte-identical in Debug, the alternated windows' pictures identical in all 10 ReleaseFast runs, corpus2x -0.039% (PASS); tui core-test 836/979 (143 skipped), shell-test 1014/1017, term-test 15/15, pane-test 183/184, kitty-test 45/45, behaviour-test 275/275 and --replay 275/275, process-test lspcomplete and lspcompletemoved (the base's) and grep (passed alone three times of three); gui unit-test 1612/1616 with the base's BaselineHarnessMismatch; replicas --clients 5 diverged 0, unequal 0, deltas wrong 0, quiet 470/0, 600/0, 764/0; daemon.py plain, --far, --games, --window-clients, --upgrade both ways (from pardes-tree's pfx-base); the macOS library for Linux and aarch64-macos and the FreeBSD tui configure; rollback-bench runs
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/views.zig')
-rw-r--r--core/views.zig27
1 files changed, 16 insertions, 11 deletions
diff --git a/core/views.zig b/core/views.zig
index b8698854..9d627a17 100644
--- a/core/views.zig
+++ b/core/views.zig
@@ -473,7 +473,7 @@ pub fn deinit(p: *Pardes) void {
for (&p.views) |*slot| if (slot.*) |*v| freeView(p, v);
}
-pub const Present = struct { ctx: ?*anyopaque, f: ?*const fn (?*anyopaque, *const pardes.Surface) void };
+pub const Present = struct { ctx: ?*anyopaque, f: ?*const fn (?*anyopaque, *const pardes.Surface) bool };
/// The view this process's frontend shows: the one open view that is no
/// replica client's (`undrawn`) and kept for none (`away`), if there is one.
@@ -482,23 +482,28 @@ pub fn shown(p: *const Pardes) ?u8 {
return null;
}
-fn drawLive(present: Present, p: *Pardes) anyerror!void {
+fn drawLive(drawn: *Drawn, p: *Pardes) anyerror!void {
_ = p.frame_arena.reset(.{ .retain_with_limit = pardes.memory.limits.frame_kept });
const surface = try p.render(p.frame_arena.allocator());
- if (present.f) |f| f(present.ctx, surface);
+ if (drawn.present.f) |f| drawn.shown = f(drawn.present.ctx, surface);
}
+const Drawn = struct { present: Present, shown: bool = true };
+
/// View `k` drawn and presented outside any step (the pump's other views,
/// a replica client's own): the live view put back after exactly as it
-/// was, so the digest is the same. No post_present.
-pub fn drawOne(p: *Pardes, k: u8, present: Present) !void {
- try within(p, k, present, drawLive);
+/// was, so the digest is the same. No post_present. Whether the frontend
+/// showed it (Host.present).
+pub fn drawOne(p: *Pardes, k: u8, present: Present) !bool {
+ var drawn: Drawn = .{ .present = present };
+ try within(p, k, &drawn, drawLive);
+ return drawn.shown;
}
/// `f(ctx, p)` with view `k` live, outside any step, and the live view put
-/// back after exactly as it was, as `drawOne` draws one: what a replica
-/// client's frontend reads of its own view (its pointer's cells, its size)
-/// while another client's input was the session's last. What going into
+/// back after exactly as it was: how `drawOne` draws one while another
+/// client's input was the session's last (a frontend reads what it needs
+/// of its view from the frame: surface.Facts). What going into
/// `k` and drawing it made of it (its layout worked out, a cursor brought
/// inside a changed text) is not kept: it is done again, in every replica
/// alike, when `k` is next live by an input.
@@ -791,7 +796,7 @@ test "drawing another view leaves the live one as it was, to the digest" {
p.toView(0);
cursorTo(p, pane, 95);
const before = pardes.walk.digest(Pardes, p);
- try drawOne(p, k, .{ .ctx = null, .f = null });
+ _ = try drawOne(p, k, .{ .ctx = null, .f = null });
try testing.expectEqual(@as(u8, 0), p.live);
try testing.expectEqual(before, pardes.walk.digest(Pardes, p));
p.toView(k);
@@ -809,7 +814,7 @@ test "a view drawn while another is live keeps its own cursors" {
try testing.expectEqual(@as(u16, 1), pane.body.nsel);
p.toView(0);
const before = pardes.walk.digest(Pardes, p);
- try drawOne(p, k, .{ .ctx = null, .f = null });
+ _ = try drawOne(p, k, .{ .ctx = null, .f = null });
try testing.expectEqual(before, pardes.walk.digest(Pardes, p));
p.toView(k);
try testing.expectEqual(@as(u16, 1), pane.body.nsel);