summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
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,