diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-19 16:03:52 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-19 16:41:06 -0300 |
| commit | d0e36bb453526af64349a4eb2335b86c94bea56d (patch) | |
| tree | 7481782dd321033ece1995372aaaec95830a8f0d /core/Core.zig | |
| parent | 8fea4ab90a04acd5f20528b00342c23d42f8c83e (diff) | |
| download | pardes-d0e36bb453526af64349a4eb2335b86c94bea56d.tar.gz pardes-d0e36bb453526af64349a4eb2335b86c94bea56d.zip | |
core: a pane's slot and a view's slot are two types, `Pane.Id` and `View.Id` (P21, pardes-ids change 1; the user, reading the tape's inputs: "why the id is an u8 though?", and "the id to be typed too"): each a distinct non-exhaustive `enum(u8)` (`pub const Id` inside `Pane` in core/panes.zig and inside `Pardes.View` in core/Core.zig, side by side with the thing whose slot it is), with the one conversion each way the boundary needs, named once: `Id.at(i)` the id of a slot the core holds (`@fromBackingInt(@intCast(i))`, so a slot past a byte panics in a safe build) and `id.index()` the slot as a `u8` (which widens to the `usize` half the core indexes with, so no caller casts); nothing uses them yet; one test at the end of core/views.zig, "a pane's id and a view's id are two types: neither is taken for the other, nor for an integer" (an enum coerces only into itself, so it shows the two are distinct, a byte each and non-exhaustive, and every slot round-trips; a probe that assigned a `View.Id` to a `Pane.Id` failed to compile with "expected type 'panes.Pane.Id', found 'Core.View.Id'"); 46 lines added in three files, no line changed; nothing a step runs is touched, so the frame and perf gate was not run on it and the semantics word does not move (313a99190b93a8c5); gate (load 5 to 10, a drat build beside): tui core-test 841/984 (143 skipped), shell-test 1020/1023, gui unit-test 1618/1622 (the perf check's BaselineHarnessMismatch, the base's 1617/1621 with it), each the base's plus this test
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/Core.zig')
| -rw-r--r-- | core/Core.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/core/Core.zig b/core/Core.zig index 769d16cd..85087b11 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -89,6 +89,21 @@ const Pardes = @This(); /// its focus, its pointer and gestures, its jumps, its key prefixes. pub const View = struct { pub const replica = .{ .len = .{ .{ "leader_keys", "leader_n" }, .{ "col_x", "ncol" }, .{ "col_w", "ncol" } } }; + /// A view's slot in `Pardes.views`, as it crosses the core's edge: an + /// entry's argument or answer, the wire's welcome. A type of its own, + /// so a pane's slot (`Pane.Id`) is not taken for it; the core's own + /// view indexes (`live`, views.zig) keep their integers. + pub const Id = enum(u8) { + _, + /// The id of slot `k`, a slot the core holds. + pub fn at(k: usize) Id { + return @fromBackingInt(@intCast(k)); + } + /// The slot, to index the core's views with. + pub fn index(id: Id) u8 { + return @backingInt(id); + } + }; screen_w: u16 = 0, screen_h: u16 = 0, |
