summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Core.zig')
-rw-r--r--core/Core.zig23
1 files changed, 19 insertions, 4 deletions
diff --git a/core/Core.zig b/core/Core.zig
index b2f96886..6c981adf 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -87,16 +87,18 @@ const Pardes = @This();
/// One client's view of the session (views.zig): its screen and layout,
/// its focus, its pointer and gestures, its jumps, its key prefixes.
pub const View = struct {
- /// Its geometry (`rects`, `col_x`, `col_w`) is the layout pass's over
- /// its columns and screen: never dumped, laid out again at a load
- /// (dump.afterLoad), as a resize lays it out.
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" } },
+ // Its geometry, read back as the session holds it (a view opened
+ // and not laid out yet has none, on a join's client too, whose
+ // kinds are told its views as the session's are): on its screen,
+ // a pane's rect and a column's `col_x` with its width (walk.zig
+ // `.within`).
+ .within = .{ .{ "rects", "onScreen" }, .{ "col_w", "columnOnScreen" } },
};
/// 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,
@@ -221,6 +223,19 @@ pub const View = struct {
return n >= 1 and n <= max_grid;
}
pub const max_grid = 4096;
+
+ /// Pane slot `id`'s rect on the screen, where the layout pass puts
+ /// every one (a frame is the screen's cells: one past it, drawn, is a
+ /// cell outside the frame).
+ pub fn onScreen(v: *const View, id: usize) bool {
+ const r = v.rects[id];
+ return @as(u32, r.x) + r.w <= v.screen_w and @as(u32, r.y) + r.h <= v.screen_h;
+ }
+
+ /// Column `c` on the screen: its left edge and its width.
+ pub fn columnOnScreen(v: *const View, c: usize) bool {
+ return @as(u32, v.col_x[c]) + v.col_w[c] <= v.screen_w;
+ }
};
gpa: std.mem.Allocator,