summaryrefslogtreecommitdiff
path: root/core/surface.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/surface.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/surface.zig')
-rw-r--r--core/surface.zig50
1 files changed, 50 insertions, 0 deletions
diff --git a/core/surface.zig b/core/surface.zig
index eb552cf1..fdcb52c8 100644
--- a/core/surface.zig
+++ b/core/surface.zig
@@ -186,6 +186,53 @@ pub const Chrome = struct {
rail_px: u8 = 12,
};
+/// What a frontend takes from the core beside the cells to draw a frame and
+/// to turn its input into events, filled with the frame (`draw.place`, in
+/// the core's `facts`, which the frame points at: a Surface made for a
+/// moment, a tag line's, copies no record): the
+/// view's size and its panes' places as they were drawn, and the settings
+/// a frontend draws by. A frontend reads this and the rest of the Surface,
+/// never the core, so a replica client needs no view of its own made live
+/// to read them.
+pub const Facts = struct {
+ pub const Pane = struct {
+ /// The pane's whole rectangle in the view, tag rows and body.
+ rect: layout.Rect = .{},
+ tag_rows: u16 = 0,
+ /// The rows a scrolling body holds at its top (Pane.context_rows).
+ context_rows: u16 = 0,
+ serial: u32 = 0,
+ kind: enum(u8) { text, terminal, addon } = .text,
+ /// A terminal whose program takes the wheel (codex, htop, less).
+ program_wheel: bool = false,
+ /// Its body in normal mode (not insert or raw).
+ normal: bool = false,
+ };
+ screen_w: u16 = 0,
+ screen_h: u16 = 0,
+ cell_pixels: pardes.CellPixels = .{},
+ row_metrics: pardes.RowMetrics = .{},
+ /// The open pane slots, and what each is.
+ open: u64 = 0,
+ panes: [MAX_PANES]Pane = undefined,
+ active: u8 = 0,
+ /// The view's jumps can go back, forward.
+ back: bool = false,
+ forward: bool = false,
+ cursor_blink: bool = true,
+ jump_trail: bool = false,
+ pet: config.Runtime.Pet = .off,
+ inactive_dim: u8 = 0,
+ tagline_percent: u8 = 100,
+
+ /// A frame no core placed (a tag line's, a test's).
+ pub const none: Facts = .{};
+
+ pub fn pane(f: *const Facts, id: usize) ?*const Pane {
+ return if (id < MAX_PANES and f.open & (@as(u64, 1) << @intCast(id)) != 0) &f.panes[id] else null;
+ }
+};
+
/// The canonical interface: what a frame of pardes IS. The tui shell writes
/// these cells to vaxis one-to-one; the SDL shells rasterize them.
pub const Surface = struct {
@@ -193,6 +240,9 @@ pub const Surface = struct {
/// `box` is acme's boxcursor, shown while a pane or a column is carried
/// by its grip (cols.c:485, rows.c:151).
pub const PointerShape = enum(u8) { arrow, link, target, box };
+ /// What a frontend reads beside the cells (Facts): the core's, filled
+ /// as this frame was placed.
+ facts: *const Facts = &Facts.none,
gpu_frames: [MAX_PANES]?GpuFrame = @splat(null),
pointer_shape: PointerShape = .arrow,
body_layers: [MAX_PANES]Layer = @splat(.{}),