summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 02:56:05 -0300
committerGabriel Schneider <[email protected]>2026-11-24 04:15:45 -0300
commit2645734806155dac927967289b0f11683eb3a1d0 (patch)
tree069a7d03c2e481d2c232cd26b53ee122a6c09be3 /core/Core.zig
parentf0f2a5125fd4b034ebcd424afd4a55c3185191ab (diff)
downloadpardes-2645734806155dac927967289b0f11683eb3a1d0.tar.gz
pardes-2645734806155dac927967289b0f11683eb3a1d0.zip
walk: a loaded index is held to what it names, and a place to its thing, by a declaration beside the field, read by the comptime walk and checked where `pastHeld` is (the end of a struct's fields in all three decoders: a tape's `decode`, a byte dump's `Loader.fields`, an image's `Get.fields`, through `holdTo`): `replica.index` says what a field names (a field's slots, a predicate's things, or, with a third word, the things of the struct holding it, held where ITS fields end over every value of the type it holds (`heldIn`, `visit`); a fourth word: a span counted from it), and one that names none is REFUSED, the field named, in the words `fromDump` and a Restore say (`Core.live says 9, which names none of Core.openViews: refused`); `replica.place` gives a field's last place (or its first and last) and one past it is that place (the session is there, its view a line off); `replica.left_out` is what a load that left a thing out (another build's pane) does to what named it before the indexes are held (`Pardes.dropMissing`, now every view's); a field that names a slot by its type (`Pane.Id`, `View.Id`) with no declaration is a compile error (`checkSlots`). RUN FIRST, each the dump fuzz with every loaded core drawn at its size, 40x12 and 200x60 and given keys and a wheel notch (core/fuzz.zig `use`), each a panic or an allocation past the fuzz's cap on the tree before: join seed 1761, `Pardes.multi_count` read as 2^30 sized a yank's register array at 17 GB (`d`, Registers.put): a step's own, now not dumped, with `multi_*`, `exec_depth`, `exec_column` (root.zig `kept_out`); join 3682, `File.State.scroll` past its text: `@intCast` into `wrap_line` (File.zig fillBody): clamped to its last line (`lastLine`; a slim dump's file, read again at its revival, to its saved bytes' lines), `scroll_row` to the top line's bytes; join 77, `Messages.head` past its ring (logMessage): clamped (`head`, `len`); restore 1211, `View.screen_h` 0, drawn (draw.zig paintHeaders: surface.zig `at`), and join 24086/28218 a screen sizing a 111 GB frame: a view's screen side is a grid a frontend sizes or the dump is refused: a cell at least (a zero refused, not clamped, as abi/wire.zig `getCols` refuses one), at most 4096 (`View.max_grid`: past any display's; the wire's 512x128 is a client's, and a session's own frontend is wider: a replica test's view is 500 rows); join 14189, `Pane.tag_lead` past i32 (Core.sync): held to the room its prefix is made in (`Pane.prefix_room`); join 18926, an undo's `Journal.done` past its steps (Text.zig `mark`): clamped, `Step.first..n` a span of the journal's entries (refused past them), and join 35489 `Journal.bytes` overflowing (`record`): held to what its entries hold. And a bitset a load made is freed with the rest when the load fails or what held it is let go (`Bits`, on `customs`): the 40,000-seed run's leak (16 KB, `Loader.value` `.bitset`), reached once a refusal came after one was read. Declared beside them, by the brief and by reading: `Pardes.live` (an open view), `theme_file_pane`; `View.active` (a pane there, or any slot in a window with none), `window_pick`, `kind_grab`, `kind_hover`; `Column.panes` (panes there, held as far as `n` now says: a `len` pair, so a digest and a dump take that far); `Pane.sized_by`, `prompt_view`, `search_pane`; `Jump.cur` (place), `Jump.Loc.pane`; the language server's awaited `pane`. TESTS (each site was a failing run first, above): walk.zig "an index read back that names none of its things is refused, its field named, in a tape, a dump and an image; a place past its thing's last is that last", "a thing another build's dump left out takes what named it with it (`left_out`), before the indexes are held"; dump.zig "a dump whose index names no view or pane there is refused, the field named; a top past its text is its last line; a key's replay is not dumped"
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.zig56
1 files changed, 52 insertions, 4 deletions
diff --git a/core/Core.zig b/core/Core.zig
index ff0a84ac..b2f96886 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -93,6 +93,10 @@ pub const View = struct {
pub const replica = .{
.len = .{ .{ "leader_keys", "leader_n" }, .{ "cols", "ncol" }, .{ "col_x", "ncol" }, .{ "col_w", "ncol" } },
.derived = .{ "rects", "col_x", "col_w" },
+ // What its keyboard is on: a pane there; window mode's outline and
+ // a kind's press and hover, slots; its screen, a grid a frontend
+ // sizes (walk.zig `.index`).
+ .index = .{ .{ "active", Pardes, "focusPanes" }, .{ "window_pick", Pardes, "panes" }, .{ "kind_grab", Pardes, "panes" }, .{ "kind_hover", Pardes, "panes" }, .{ "screen_w", "grids" }, .{ "screen_h", "grids" } },
};
/// 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,
@@ -208,6 +212,15 @@ pub const View = struct {
pastes: u32 = 0,
links: u32 = 0,
link: pardes.Effect.Buf(256) = .{},
+
+ /// A side of a grid a frontend sizes: a cell at least (a zero is
+ /// refused, not clamped, as the wire refuses one: abi/wire.zig
+ /// `getCols`), past no display's (a frame is as many cells as it
+ /// holds, Surface.cells: a damaged image's asked 111 GB).
+ pub fn grids(_: *const View, n: usize) bool {
+ return n >= 1 and n <= max_grid;
+ }
+ pub const max_grid = 4096;
};
gpa: std.mem.Allocator,
@@ -481,6 +494,11 @@ pub const replica = .{
"in_head", "in_len",
// The views no frontend here draws (views.zig).
"undrawn",
+ // A step's own, set and put back within it (a key's replay across
+ // the ranges, normal.replaySels; a word's run, exec.zig): as
+ // `init` makes them between any two steps.
+ "multi_first", "multi_stop", "multi_index",
+ "multi_count", "exec_depth", "exec_column",
// How this process was started, and the last dump it made for
// its host to write: a session loaded elsewhere has its own.
"opts", "dump_out", "dump_export",
@@ -493,8 +511,38 @@ pub const replica = .{
// server's own part of `fs` says so in fs.Namespace.)
.authority = .{ "host", "store", "recent", "db", "fallback" },
.len = .{ .{ "look_src", "n_look_src" }, .{ "session_dir", "session_dir_len" }, .{ "session_home", "session_home_len" }, .{ "session_shell", "session_shell_len" } },
+ // The live view is an open one; a ThemeFile's pane a slot (walk.zig
+ // `.index`).
+ .index = .{ .{ "live", "openViews" }, .{ "theme_file_pane", "panes" } },
+ // A pane another build's dump could not give: out of every layout.
+ .left_out = "dropMissing",
};
+/// What an index into the session names (walk.zig `.index`): an open view.
+pub fn openViews(p: *const Pardes, k: usize) bool {
+ return k < Views.max and p.views[k] != null;
+}
+
+/// A pane there.
+pub fn openPanes(p: *const Pardes, id: usize) bool {
+ return id < MAX_PANES and p.panes[id] != null;
+}
+
+/// What a view's keyboard may be on: a pane there, or any slot in a window
+/// with none (the last column's Delcol leaves one, layout.zig `delColumn`).
+pub fn focusPanes(p: *const Pardes, id: usize) bool {
+ if (id >= MAX_PANES) return false;
+ if (p.panes[id] != null) return true;
+ return for (p.panes) |slot| {
+ if (slot != null) break false;
+ } else true;
+}
+
+/// The panes a view's columns list that are not there (another build's
+/// dump left them out: walk.zig `left_out`) taken out of them, and its
+/// keyboard on one that is.
+pub const dropMissing = pardes.dump.dropMissing;
+
/// The message row's entry points, called from everywhere as
/// `p.setMessage(...)`; they live with the rest of it in Messages.zig.
pub const setStatus = Messages.setStatus;
@@ -1929,7 +1977,7 @@ pub fn sync(p: *Pardes) void {
// had any; a folded pane shows its first line only. Its prefix
// is made once, on the stack: this runs on every event, and not
// every event may take from the scratch arena.
- var wrap_room: [32 * 1024]u8 = undefined;
+ var wrap_room: [Pane.prefix_room]u8 = undefined;
var wrap_fba = std.heap.FixedBufferAllocator.init(&wrap_room);
const wa = wrap_fba.allocator();
const prefix: ?[]const u8 = tagline.prefixIn(p, wa, pane) catch null;
@@ -2223,9 +2271,9 @@ pub const PendingWrite = struct { bytes: []u8, off: usize = 0 };
/// place on screen (`col_x`, `col_w`) is worked out each sync, as a pane's
/// rect is.
pub const Column = struct {
- // Zeroed, not undefined: a digest takes the whole of it, a release
- // build's heap leaves its unused slots whatever was there before, and
- // two replicas must agree on them (core/replica.zig).
+ /// Its panes, as far as `n` says (what a digest, a dump and a copy take),
+ /// each a pane there (walk.zig `.index`).
+ pub const replica = .{ .len = .{.{ "panes", "n" }}, .index = .{.{ "panes", Pardes, "openPanes" }} };
panes: [MAX_PANES]usize = @splat(0),
n: usize = 0,
weight: u64 = column_weight_unit,