summaryrefslogtreecommitdiff
path: root/core/surface.zig
diff options
context:
space:
mode:
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(.{}),