summaryrefslogtreecommitdiff
path: root/core/draw.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/draw.zig')
-rw-r--r--core/draw.zig45
1 files changed, 45 insertions, 0 deletions
diff --git a/core/draw.zig b/core/draw.zig
index f4b08635..f41674cb 100644
--- a/core/draw.zig
+++ b/core/draw.zig
@@ -36,6 +36,47 @@ const MAX_COLS = pardes.MAX_COLS;
const MAX_TAG_ROWS = pardes.MAX_TAG_ROWS;
const NOTICE_LAYER_BASE = pardes.NOTICE_LAYER_BASE;
+/// What a frontend reads beside the cells (surface.Facts), of the live
+/// view as it is now: with each frame (`place`), and by a runner after an
+/// input it applied, outside any step, writing nothing of the core's.
+pub fn facts(p: *const Pardes, f: *pardes.Facts) void {
+ viewFacts(p, f);
+ for (p.panes, 0..) |slot, id| if (slot) |pane| paneFacts(p, f, id, pane);
+}
+
+/// The view's facts; its panes' table emptied (`paneFacts` fills it).
+fn viewFacts(p: *const Pardes, f: *pardes.Facts) void {
+ const v = p.view();
+ // Field by field: the panes' table is written only where a pane is.
+ f.screen_w = v.screen_w;
+ f.screen_h = v.screen_h;
+ f.cell_pixels = v.cell_pixels;
+ f.row_metrics = v.row_metrics;
+ f.open = 0;
+ f.active = @intCast(v.active);
+ f.back = v.jumps.n > 0 and v.jumps.cur > 0;
+ f.forward = v.jumps.n > 0 and v.jumps.cur + 1 < v.jumps.n;
+ f.cursor_blink = p.settings.cursor_blink;
+ f.jump_trail = p.settings.jump_trail;
+ f.pet = p.settings.pet;
+ f.inactive_dim = p.settings.inactive_dim;
+ f.tagline_percent = p.settings.font.tagline_percent;
+}
+
+/// Open pane `id`'s facts.
+fn paneFacts(p: *const Pardes, f: *pardes.Facts, id: usize, pane: *const Pane) void {
+ f.open |= @as(u64, 1) << @intCast(id);
+ f.panes[id] = .{
+ .rect = p.view().rects[id],
+ .tag_rows = pane.tag_rows,
+ .context_rows = pane.context_rows,
+ .serial = pane.serial,
+ .kind = if (pane.addon != null) .addon else if (pane.isTerminal()) .terminal else .text,
+ .program_wheel = pane.isTerminal() and panes.Term.modes(pane.terminal).wheel,
+ .normal = pane.body.mode == .normal,
+ };
+}
+
/// Where every part of the frame goes, decided once before anything is
/// painted: the page; each pane's grip, tag, body, rail (with its thumb)
/// and notice chips; each column's grip and tag; the workspace tag. The
@@ -44,9 +85,13 @@ pub fn place(p: *Pardes, s: *Surface) void {
const v = p.view();
s.nregions = 0;
s.nrail_ticks = 0;
+ // The facts filled in the walk the frame's places take anyway.
+ viewFacts(p, &p.facts);
+ s.facts = &p.facts;
s.addRegion(.{ .kind = .page, .rect = .{ .x = 0, .y = 0, .w = s.cols, .h = s.rows } });
for (&p.panes, 0..) |*slot, id| {
const pane = slot.* orelse continue;
+ paneFacts(p, &p.facts, id, pane);
Messages.collectNotices(p, pane, v.rects[id], id);
const r = v.rects[id];
if (r.w <= config.GUTTER or r.h == 0) continue;