summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/Core.zig40
-rw-r--r--core/draw.zig45
-rw-r--r--core/replica.zig29
-rw-r--r--core/rollback.zig2
-rw-r--r--core/root.zig1
-rw-r--r--core/surface.zig50
-rw-r--r--core/tape.zig2
-rw-r--r--core/views.zig27
-rw-r--r--dev/Host.zig5
-rw-r--r--dev/gui/gui.zig382
-rw-r--r--dev/tui/tui.zig85
-rw-r--r--runtime/macos.zig5
-rw-r--r--test/replicas.zig38
-rw-r--r--test/rollback_bench.zig2
14 files changed, 439 insertions, 274 deletions
diff --git a/core/Core.zig b/core/Core.zig
index 398d5973..0e37f945 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -282,8 +282,12 @@ theme_file_loaded: config.Runtime.Text(limits.host_path_cap) = .{},
theme_file_generation: u32 = 0,
theme_file_pane: u8 = 0,
chrome: colors.ChromeTheme = colors.initial_chrome,
-/// Every drawn frame's timings (FrameStats: the Debug box, PARDES_FRAMES).
-frames: FrameStats = .{},
+/// Every drawn frame's timings (FrameStats: the Debug box, PARDES_FRAMES):
+/// its runner's (`Options.frames`), which its frontend writes as it draws
+/// and reads input, never the core's memory; a core with no runner (a
+/// test's) has its own.
+frames: *FrameStats = undefined,
+own_frames: FrameStats = .{},
quit: bool = false,
/// A detached session with no frontend attached: nothing renders, so
/// no input ever dismisses a message (Messages.expireUnattended).
@@ -334,9 +338,6 @@ boot: Boot = .shell,
/// Is there a frame worth drawing? Cleared once one is presented, set by
/// anything that can change what is on screen. The first frame always is.
needs_frame: bool = true,
-/// Set by a shell whose present was skipped (no swapchain image): the
-/// frame is still owed, and the next pump draws it again.
-present_skipped: bool = false,
clock: Clock = .{},
/// Builtins announce themselves on the message row. Off while startup
/// configuration is applied: those lines are nobody clicking, and should
@@ -388,6 +389,9 @@ restore_req: ?[]const u8 = null,
restore_buf: [1024]u8 = @splat(0),
surface: Surface = .{},
+/// What a frontend reads beside the frame's cells (surface.Facts), filled
+/// as it is placed (draw.place); the frame points at it.
+facts: pardes.Facts = .{},
/// A replica's predicted echo (core/term/echo.zig), drawn over its terminals:
/// presentation, its own, in no digest and no rollback copy. Null on a
/// session's own core.
@@ -427,9 +431,11 @@ diff_output: pardes.ansi.DiffOutput = .{},
pub const replica = .{
.local = .{
// A frame, and the timings that make it.
- "surface", "frames", "chrome",
+ "surface", "facts", "frames",
+ "own_frames",
+ "chrome",
"frame_arena", "scratch", "needs_frame",
- "present_skipped", "echo",
+ "echo",
// Drained by every pump before its digest; a replica's queues
// are its own.
"effects",
@@ -522,6 +528,7 @@ pub fn create(gpa: std.mem.Allocator, opts: Options) !*Pardes {
.fallback = .{ .gpa = gpa },
.db = .{ .kind = opts.state },
};
+ p.frames = opts.frames orelse &p.own_frames;
errdefer p.deinit();
p.fs.started = ctlfs.events.now();
for (opts.mounts) |mount| try p.fs.mount(gpa, mount.name, mount.dial);
@@ -1499,23 +1506,23 @@ pub fn pump(p: *Pardes, host: Host) !void {
if (v.watched) |f| if (!f(h.ctx)) return;
// The one view this process shows (a replica client's is its own
// process's to draw), drawn as it is if another's is live.
+ // Not shown by the frontend (Host.present): owed.
+ var skipped = false;
const shown = Views.shown(p);
if (shown != p.live) {
- if (shown) |k| try Views.drawOne(p, k, .{ .ctx = h.ctx, .f = v.present });
+ if (shown) |k| skipped = !try Views.drawOne(p, k, .{ .ctx = h.ctx, .f = v.present });
} else {
_ = p.frame_arena.reset(.{ .retain_with_limit = memory.limits.frame_kept });
p.frames.mark_update = FrameStats.nowNs();
p.frames.view = if (p.panes[p.view().active]) |pane| pane.scroll() else 0;
const surface = try p.render(p.frame_arena.allocator());
p.frames.mark_render = FrameStats.nowNs();
- if (v.present) |f| f(h.ctx, surface);
+ if (v.present) |f| skipped = !f(h.ctx, surface);
Stream.askAhead(p);
}
// Settled before post_present: a shell ticks there, and what that
// tick moves owes the next frame.
- const skipped = p.present_skipped;
- p.needs_frame = p.present_skipped;
- p.present_skipped = false;
+ p.needs_frame = skipped;
if (v.post_present) |f| f(h.ctx);
// Still moving: the next frame is owed a period from now.
const owed = if (p.nextWake()) |due| due <= p.clock.stepped_ns + frame_ns else false;
@@ -2234,7 +2241,9 @@ pub const Boot = enum {
};
pub const Options = struct {
- pub const replica = .{ .local = .{"distrusted"} };
+ /// Not taped: the client's list of distrusted kinds, and where its
+ /// runner keeps its frame statistics.
+ pub const replica = .{ .local = .{ "distrusted", "frames" } };
tty_only: bool = false,
/// The first view's frontend is a window (`Pardes.frontend`), as a
/// window's build says: an option, taped with the rest, so that a
@@ -2285,6 +2294,8 @@ pub const Options = struct {
/// Where each frame's Surface text is built. Hosts pass a purpose-built
/// stack-fallback arena; null means the general allocator.
frame_allocator: ?std.mem.Allocator = null,
+ /// The runner's frame statistics (`Pardes.frames`); null: the core's own.
+ frames: ?*FrameStats = null,
cols: u16 = 80,
rows: u16 = 24,
};
@@ -2715,8 +2726,9 @@ test "a frame no one watches is not drawn, and is drawn once someone does" {
var presents: usize = 0;
var seen = false;
const vtable: Host.VTable = .{ .present = present, .watched = watched };
- fn present(_: ?*anyopaque, _: *const Surface) void {
+ fn present(_: ?*anyopaque, _: *const Surface) bool {
presents += 1;
+ return true;
}
fn watched(_: ?*anyopaque) bool {
return seen;
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;
diff --git a/core/replica.zig b/core/replica.zig
index 993c1f09..31a06214 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -1230,20 +1230,14 @@ pub const Replica = struct {
/// Its own view drawn and presented through `present`, between steps
/// (views.drawOne): nothing the digest covers moves. The epoch's trees
/// held while a copy is (a render can make or drop a syntax tree).
- pub fn draw(r: *Replica, present: pardes.views.Present) void {
+ pub fn draw(r: *Replica, present: pardes.views.Present) bool {
rollback.Epoch.select(&r.epoch);
defer rollback.Epoch.select(null);
- pardes.views.drawOne(r.core(), r.view, present) catch {};
- }
-
- /// `f(ctx, core)` with its own view live, outside any step, as `draw`
- /// draws it (views.within): what its frontend reads of its own view
- /// (its pointer's cells, its size) while another client's input was the
- /// session's last.
- pub fn within(r: *Replica, ctx: anytype, comptime f: fn (@TypeOf(ctx), *Pardes) anyerror!void) void {
- rollback.Epoch.select(&r.epoch);
- defer rollback.Epoch.select(null);
- pardes.views.within(r.core(), r.view, ctx, f) catch {};
+ // A frame drawing owes another is this process's, not the core's.
+ const c = r.core();
+ const needs = c.needs_frame;
+ defer c.needs_frame = needs;
+ return pardes.views.drawOne(c, r.view, present) catch true;
}
/// One of the authority's terminal messages (`Screens.flush`, or an
@@ -4180,14 +4174,14 @@ test "a replica joined from a themed dump paints its taglines in the restored th
try std.testing.expectEqualStrings("rose_pine_moon", r.core().theme().name);
try std.testing.expectEqual(expected.tag_bg, r.core().chromeTheme().tag_bg);
try std.testing.expectEqual(expected.tag_fg, r.core().chromeTheme().tag_fg);
- r.draw(.{ .ctx = null, .f = null });
+ _ = r.draw(.{ .ctx = null, .f = null });
try std.testing.expectEqual(expected.tag_bg, r.core().surface.chrome.tag_bg);
try std.testing.expectEqual(expected.tag_fg, r.core().surface.chrome.tag_fg);
try std.testing.expectEqual(digestOf(a), r.digest());
// A later theme is an ordinary confirmed unit, its chrome set at once.
r.confirm(try a.local(.{ .command = "Theme monokai_pro_classic" }));
r.settle();
- r.draw(.{ .ctx = null, .f = null });
+ _ = r.draw(.{ .ctx = null, .f = null });
const changed = pardes.colors.ChromeTheme.fromTheme(a.core.theme());
try std.testing.expectEqual(changed.tag_bg, r.core().surface.chrome.tag_bg);
try std.testing.expectEqual(changed.tag_fg, r.core().surface.chrome.tag_fg);
@@ -4962,9 +4956,10 @@ test "a closed terminal with a kitty image brought back on a client: its image d
r.confirm(try a.local(.{ .focus = true }));
const Seen = struct {
px: ?[4]u8 = null,
- fn take(ctx: ?*anyopaque, s: *const pardes.Surface) void {
+ fn take(ctx: ?*anyopaque, s: *const pardes.Surface) bool {
const seen: *@This() = @ptrCast(@alignCast(ctx.?));
for (s.placements.items) |pl| seen.px = pl.raster.bytes()[0..4].*;
+ return true;
}
};
var sent: std.ArrayListUnmanaged([]u8) = .empty;
@@ -4976,13 +4971,13 @@ test "a closed terminal with a kitty image brought back on a client: its image d
try key(r, 'o', &sent);
try std.testing.expect(r.copy.held);
var seen: Seen = .{};
- r.draw(.{ .ctx = &seen, .f = Seen.take });
+ _ = r.draw(.{ .ctx = &seen, .f = Seen.take });
try std.testing.expectEqual([4]u8{ 0x11, 0x22, 0x33, 0xff }, seen.px.?);
// The session's own key first: back to the copy, the key applied again.
r.confirm(try a.local(.{ .key = .{ .cp = 'l', .text = "l" } }));
r.settle();
seen = .{};
- r.draw(.{ .ctx = &seen, .f = Seen.take });
+ _ = r.draw(.{ .ctx = &seen, .f = Seen.take });
try std.testing.expectEqual([4]u8{ 0x11, 0x22, 0x33, 0xff }, seen.px.?);
r.confirm(try a.take(sent.items[0]));
r.settle();
diff --git a/core/rollback.zig b/core/rollback.zig
index a17e47ba..a6c6e5bd 100644
--- a/core/rollback.zig
+++ b/core/rollback.zig
@@ -525,7 +525,7 @@ fn annotatedStruct(comptime T: type) bool {
/// step reads what the authority holds of them off the tape
/// (tape.authority), never a replica's.
fn unsaved(comptime name: []const u8) bool {
- return std.mem.eql(u8, name, "effects") or std.mem.eql(u8, name, "in_q") or std.mem.eql(u8, name, "frames") or
+ return std.mem.eql(u8, name, "effects") or std.mem.eql(u8, name, "in_q") or std.mem.eql(u8, name, "frames") or std.mem.eql(u8, name, "own_frames") or
std.mem.eql(u8, name, "shell_rows") or std.mem.eql(u8, name, "echo") or std.mem.eql(u8, name, "store") or
std.mem.eql(u8, name, "recent");
}
diff --git a/core/root.zig b/core/root.zig
index c10a2598..04909bd7 100644
--- a/core/root.zig
+++ b/core/root.zig
@@ -51,6 +51,7 @@ pub const NativeGeometry = @import("surface.zig").NativeGeometry;
pub const containGeometry = @import("surface.zig").containGeometry;
pub const RectCell = @import("surface.zig").RectCell;
pub const Surface = @import("surface.zig").Surface;
+pub const Facts = @import("surface.zig").Facts;
pub const Region = @import("surface.zig").Region;
pub const Chrome = @import("surface.zig").Chrome;
pub const RailTick = @import("surface.zig").RailTick;
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(.{}),
diff --git a/core/tape.zig b/core/tape.zig
index 2b9272a6..270147c2 100644
--- a/core/tape.zig
+++ b/core/tape.zig
@@ -176,7 +176,7 @@ pub const shape = blk: {
};
/// Fields a host writes straight into the core between its calls.
-const watched = .{ "frontend", "present_skipped", "needs_frame", "quit", "active", "unattended" };
+const watched = .{ "frontend", "needs_frame", "quit", "active", "unattended" };
/// Watched field `name` of `p`: the live view's, or the session's.
fn watchedOf(p: *Pardes, comptime name: []const u8) *Watched(name) {
diff --git a/core/views.zig b/core/views.zig
index b8698854..9d627a17 100644
--- a/core/views.zig
+++ b/core/views.zig
@@ -473,7 +473,7 @@ pub fn deinit(p: *Pardes) void {
for (&p.views) |*slot| if (slot.*) |*v| freeView(p, v);
}
-pub const Present = struct { ctx: ?*anyopaque, f: ?*const fn (?*anyopaque, *const pardes.Surface) void };
+pub const Present = struct { ctx: ?*anyopaque, f: ?*const fn (?*anyopaque, *const pardes.Surface) bool };
/// The view this process's frontend shows: the one open view that is no
/// replica client's (`undrawn`) and kept for none (`away`), if there is one.
@@ -482,23 +482,28 @@ pub fn shown(p: *const Pardes) ?u8 {
return null;
}
-fn drawLive(present: Present, p: *Pardes) anyerror!void {
+fn drawLive(drawn: *Drawn, p: *Pardes) anyerror!void {
_ = p.frame_arena.reset(.{ .retain_with_limit = pardes.memory.limits.frame_kept });
const surface = try p.render(p.frame_arena.allocator());
- if (present.f) |f| f(present.ctx, surface);
+ if (drawn.present.f) |f| drawn.shown = f(drawn.present.ctx, surface);
}
+const Drawn = struct { present: Present, shown: bool = true };
+
/// View `k` drawn and presented outside any step (the pump's other views,
/// a replica client's own): the live view put back after exactly as it
-/// was, so the digest is the same. No post_present.
-pub fn drawOne(p: *Pardes, k: u8, present: Present) !void {
- try within(p, k, present, drawLive);
+/// was, so the digest is the same. No post_present. Whether the frontend
+/// showed it (Host.present).
+pub fn drawOne(p: *Pardes, k: u8, present: Present) !bool {
+ var drawn: Drawn = .{ .present = present };
+ try within(p, k, &drawn, drawLive);
+ return drawn.shown;
}
/// `f(ctx, p)` with view `k` live, outside any step, and the live view put
-/// back after exactly as it was, as `drawOne` draws one: what a replica
-/// client's frontend reads of its own view (its pointer's cells, its size)
-/// while another client's input was the session's last. What going into
+/// back after exactly as it was: how `drawOne` draws one while another
+/// client's input was the session's last (a frontend reads what it needs
+/// of its view from the frame: surface.Facts). What going into
/// `k` and drawing it made of it (its layout worked out, a cursor brought
/// inside a changed text) is not kept: it is done again, in every replica
/// alike, when `k` is next live by an input.
@@ -791,7 +796,7 @@ test "drawing another view leaves the live one as it was, to the digest" {
p.toView(0);
cursorTo(p, pane, 95);
const before = pardes.walk.digest(Pardes, p);
- try drawOne(p, k, .{ .ctx = null, .f = null });
+ _ = try drawOne(p, k, .{ .ctx = null, .f = null });
try testing.expectEqual(@as(u8, 0), p.live);
try testing.expectEqual(before, pardes.walk.digest(Pardes, p));
p.toView(k);
@@ -809,7 +814,7 @@ test "a view drawn while another is live keeps its own cursors" {
try testing.expectEqual(@as(u16, 1), pane.body.nsel);
p.toView(0);
const before = pardes.walk.digest(Pardes, p);
- try drawOne(p, k, .{ .ctx = null, .f = null });
+ _ = try drawOne(p, k, .{ .ctx = null, .f = null });
try testing.expectEqual(before, pardes.walk.digest(Pardes, p));
p.toView(k);
try testing.expectEqual(@as(u16, 1), pane.body.nsel);
diff --git a/dev/Host.zig b/dev/Host.zig
index 0dc2ae6c..1834e52e 100644
--- a/dev/Host.zig
+++ b/dev/Host.zig
@@ -10,7 +10,10 @@ pub const VTable = struct {
/// The shell's monotonic clock in ns: the only time the core sees.
/// Without one, core animation moves only by `.tick` events.
now: ?*const fn (ctx: ?*anyopaque) u64 = null,
- present: ?*const fn (ctx: ?*anyopaque, surface: *const pardes.Surface) void = null,
+ /// The frame drawn on the frontend: false when it could not show it
+ /// now (no image to draw into, the terminal still answering the last),
+ /// which owes the next frame.
+ present: ?*const fn (ctx: ?*anyopaque, surface: *const pardes.Surface) bool = null,
post_present: ?*const fn (ctx: ?*anyopaque) void = null,
poll_frame: ?*const fn (ctx: ?*anyopaque) void = null,
/// Whether anyone sees a frame drawn now. A detached session with no
diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig
index 2e22e537..a632f67a 100644
--- a/dev/gui/gui.zig
+++ b/dev/gui/gui.zig
@@ -196,8 +196,9 @@ fn updateCoreResize(core: *pardes.Pardes, cols: u16, rows: u16, cell_w: u32, cel
}
/// The resize a window of `cols` by `rows` cells of these sizes is to the
-/// live view, or null when it is that already.
-fn resizeOf(v: *const pardes.Pardes.View, cols: u16, rows: u16, cell_w: u32, cell_h: u32, tag_w: u32, tag_h: u32) ?pardes.Event {
+/// live view (a View, or the Facts a frame carries of it), or null when it
+/// is that already.
+fn resizeOf(v: anytype, cols: u16, rows: u16, cell_w: u32, cell_h: u32, tag_w: u32, tag_h: u32) ?pardes.Event {
const metrics: pardes.RowMetrics = .{ .body_w = @intCast(cell_w), .body_h = @intCast(cell_h), .tagline_w = @intCast(tag_w), .tagline_h = @intCast(tag_h) };
const same_metrics = std.meta.eql(metrics, v.row_metrics);
const cell_px_w: u16 = @intCast(@min(@max(1, cell_w), std.math.maxInt(u16)));
@@ -329,7 +330,7 @@ fn takeScrollTicks(accum: *f32) i32 {
return ticks;
}
-fn handleFinger(t: *Touch, in: *Input, f: Finger, win_w: f32, win_h: f32, cell_w: f32, cell_h: f32, tagline_w: f32) void {
+fn handleFinger(g: *const Gui, t: *Touch, in: *Input, f: Finger, win_w: f32, win_h: f32, cell_w: f32, cell_h: f32, tagline_w: f32) void {
std.debug.assert(cell_w > 0 and cell_h > 0);
switch (f.kind) {
.down => {
@@ -342,27 +343,27 @@ fn handleFinger(t: *Touch, in: *Input, f: Finger, win_w: f32, win_h: f32, cell_w
t.syncPair();
if (!had_pair) return;
const res = t.noteMotion(f) orelse return;
- emitTouchScroll(in, res.center, res.ticks, win_w, win_h, cell_w, cell_h, tagline_w);
+ emitTouchScroll(g, in, res.center, res.ticks, win_w, win_h, cell_w, cell_h, tagline_w);
},
.up, .cancel => {
const tap_center = t.finishPair(f);
t.updatePoint(f);
t.syncPair();
- if (tap_center) |center| emitTouchClick(in, center, .middle, win_w, win_h, cell_w, cell_h, tagline_w);
+ if (tap_center) |center| emitTouchClick(g, in, center, .middle, win_w, win_h, cell_w, cell_h, tagline_w);
},
}
}
-fn emitTouchScroll(in: *Input, center: TouchNormPoint, ticks: i32, win_w: f32, win_h: f32, cell_w: f32, cell_h: f32, tagline_w: f32) void {
- const cell = gridCellAtDimensions(in.core, center.x * win_w, center.y * win_h, cell_w, cell_h, tagline_w);
+fn emitTouchScroll(g: *const Gui, in: *Input, center: TouchNormPoint, ticks: i32, win_w: f32, win_h: f32, cell_w: f32, cell_h: f32, tagline_w: f32) void {
+ const cell = gridCellAtDimensions(g, center.x * win_w, center.y * win_h, cell_w, cell_h, tagline_w);
const button: pardes.Mouse.Button = if (ticks > 0) .wheel_up else .wheel_down;
var remaining: u32 = @abs(ticks);
while (remaining > 0) : (remaining -= 1)
in.post(.{ .mouse = .{ .button = button, .kind = .press, .col = cell.col, .row = cell.row, .tag_hit = cell.tag_hit, .body_hit = cell.body_hit } });
}
-fn emitTouchClick(in: *Input, point: TouchNormPoint, button: pardes.Mouse.Button, win_w: f32, win_h: f32, cell_w: f32, cell_h: f32, tagline_w: f32) void {
- const cell = gridCellAtDimensions(in.core, point.x * win_w, point.y * win_h, cell_w, cell_h, tagline_w);
+fn emitTouchClick(g: *const Gui, in: *Input, point: TouchNormPoint, button: pardes.Mouse.Button, win_w: f32, win_h: f32, cell_w: f32, cell_h: f32, tagline_w: f32) void {
+ const cell = gridCellAtDimensions(g, point.x * win_w, point.y * win_h, cell_w, cell_h, tagline_w);
in.post(.{ .mouse = .{ .button = button, .kind = .press, .col = cell.col, .row = cell.row, .tag_hit = cell.tag_hit, .body_hit = cell.body_hit } });
in.post(.{ .mouse = .{ .button = button, .kind = .release, .col = cell.col, .row = cell.row, .tag_hit = cell.tag_hit, .body_hit = cell.body_hit } });
}
@@ -527,6 +528,13 @@ const Gui = struct {
/// The core the hit test asks (hitTest), while a local session runs;
/// null attached, where the session's tag is another process's.
hit_core: ?*pardes.Pardes = null,
+ /// The frame it shows, and what it reads beside the cells to draw it and
+ /// to turn its input into events (pardes.Facts): set as it presents,
+ /// refreshed by its runner after each input it applied. Never the core.
+ frame: ?*const pardes.Surface = null,
+ facts: pardes.Facts = .{},
+ /// The key Ctrl takes to toggle a terminal (Options.tty_toggle).
+ tty_toggle: u21 = pardes.config.tty_toggle_default,
/// Pixels the capture holds past the grid (PARDES_TEST_PAD).
capture_pad: u32 = 0,
@@ -585,8 +593,7 @@ fn acknowledgeGuiFont(g: *const Gui, core: *pardes.Pardes) void {
/// A replica client's font is the window's raster state: it follows the
/// session's request by the face's name on this machine (fonts.fromSession),
/// never acknowledging it or otherwise changing the replicated core.
-fn syncReplicaFont(g: *Gui, core: *const pardes.Pardes, gpa: std.mem.Allocator) bool {
- const f = &core.settings.font;
+fn syncReplicaFont(g: *Gui, f: *const @FieldType(pardes.config.Runtime, "font"), gpa: std.mem.Allocator) bool {
const path = f.requested_path.get();
const name = f.requested_name.get();
if (path.len == 0 and name.len == 0) return false;
@@ -928,6 +935,7 @@ fn runNative(init: std.process.Init, opts_in: pardes.Options, detached: bool, di
var g: Gui = .{
.window = window,
+ .tty_toggle = opts_in.tty_toggle,
.arrow_cursor = arrow_cursor,
.link_cursor = link_cursor,
.box_cursor = box_cursor,
@@ -1027,6 +1035,9 @@ fn localSession(
defer host_io.stopWorkers();
var opts = opts_in;
opts.addons = pardes.Addon.scan();
+ // Its frame timings, the window's to write as it draws (Pardes.frames).
+ var frames: pardes.FrameStats = .{};
+ opts.frames = &frames;
opts.image_allocator = allocs.image;
opts.tree_sitter_allocator = allocs.tree_sitter;
opts.frame_allocator = allocs.frame;
@@ -1113,7 +1124,7 @@ fn localSession(
defer shell.shutdownPtys();
// A virtual clock never blinks: goldens and feel series hold still.
g.no_blink = shell.test_clock != null;
- frame_probe = &core.frames;
+ frame_probe = &frames;
frame_capture_dir = if (std.c.getenv("PARDES_FRAMES_CAPTURE")) |dir| std.mem.span(dir) else null;
const host = shell.host();
core.host = host;
@@ -1184,7 +1195,6 @@ fn localSession(
nc.view().frontend.windowed = true;
core.deinit();
core = nc;
- frame_probe = &nc.frames; // the old core's ring went with it
g.hit_core = nc;
shell.core = nc;
shell.surface = null;
@@ -1201,14 +1211,13 @@ fn localSession(
}
/// A window's link to a session elsewhere (`clientSession`): what the
-/// window's input made, fed to the replica once its own view is put back,
-/// and what the link's reader took off the stream.
+/// window's input made, fed to the replica after each event, and what the
+/// link's reader took off the stream.
const Client = struct {
link: replica.Link,
io: std.Io,
gpa: std.mem.Allocator,
- /// The window's inputs since the last feed, their texts in `texts`:
- /// read over its own view (`Replica.within`), applied after it.
+ /// The window's inputs since the last feed, their texts in `texts`.
pending: std.ArrayListUnmanaged(pardes.Event) = .empty,
texts: std.heap.ArenaAllocator,
/// The reader's, under `lock`: what it took, and whether the link ended.
@@ -1239,16 +1248,18 @@ const Client = struct {
cl.pending.append(cl.gpa, e) catch {};
}
- /// What the window's input made, applied at once and sent.
- fn feed(cl: *Client) void {
+ /// What the window's input made, applied at once and sent; what the
+ /// window reads beside its frame (Gui.facts) as its view is now.
+ fn feed(cl: *Client, g: *Gui) void {
+ const r = cl.link.r;
for (cl.pending.items) |ev| {
- const r = cl.link.r;
const predicted = r.echo.stats.predicted;
cl.link.input(ev);
// PARDES_TEST_LATENCY: the input, and whether it shows at once
// (applied, or its echo predicted), for the frame that shows it.
latencyNote("I {d} {d} {d}\n", .{ r.next_seq - 1, monoNs(), @intFromBool(r.applied == r.pending.items.len or r.echo.stats.predicted > predicted) });
}
+ if (cl.pending.items.len > 0 and r.core().live == r.view) pardes.draw.facts(r.core(), &g.facts);
cl.pending.clearRetainingCapacity();
_ = cl.texts.reset(.retain_capacity);
}
@@ -1286,22 +1297,16 @@ const Client = struct {
}
/// Its own view drawn in the window, outside any step, as the tty's
- /// client draws its terminal (tui.zig `Client.draw`): what presenting
- /// writes in the core (a frame skipped, one owed) is put back.
+ /// client draws its terminal (tui.zig `Client.draw`), its timings this
+ /// process's (`frame_probe`).
fn draw(cl: *Client, s: *Shell) void {
- const r = cl.link.r;
- const core = r.core();
- const skipped = core.present_skipped;
- const needs = core.needs_frame;
- core.frames.mark_start = pardes.FrameStats.nowNs();
- core.frames.mark_update = core.frames.mark_start;
+ const frames = frame_probe.?;
+ frames.mark_start = pardes.FrameStats.nowNs();
+ frames.mark_update = frames.mark_start;
// Its render's end is marked as it presents (`present`).
- core.frames.mark_render = core.frames.mark_update;
- r.draw(.{ .ctx = s, .f = present });
- cl.link.owed = core.present_skipped;
- core.frames.record(pardes.FrameStats.nowNs(), if (s.gui) |g| frontendMoving(g) else false, cl.link.owed);
- core.present_skipped = skipped;
- core.needs_frame = needs;
+ frames.mark_render = frames.mark_update;
+ cl.link.owed = !cl.link.r.draw(.{ .ctx = s, .f = present });
+ frames.record(pardes.FrameStats.nowNs(), if (s.gui) |g| frontendMoving(g) else false, cl.link.owed);
cl.link.drawn(s.presented);
}
};
@@ -1315,38 +1320,6 @@ fn clientReader(cl: *Client, fd: c_int, rest: *replica.Framer) void {
sdlWake(null);
}
-/// What the window does over its own view (`Replica.within`), its inputs
-/// posted to the client (`Input.client`): an SDL event dispatched, its size
-/// (the tagline's face too), the pointer under a frame that moved, the
-/// timedemo's and the test feed's steps.
-const OwnView = struct {
- g: *Gui,
- in: *Input,
- s: *Shell,
- sev: ?*const c.SDL_Event = null,
- pointer: bool = false,
- eof: bool = false,
-
- fn run(v: *OwnView, core: *pardes.Pardes) anyerror!void {
- if (v.sev) |sev| return dispatch(v.g, v.in, sev);
- const g = v.g;
- if (syncReplicaFont(g, core, v.s.gpa)) v.s.client.?.link.dirty = true;
- if (scrollRows(g, v.in, v.s.gpa)) v.s.client.?.link.dirty = true;
- if (fitTaglineFont(g, core.settings.font.tagline_percent)) v.s.client.?.link.dirty = true;
- const geom = windowCells(g);
- const cl = v.s.client.?;
- if (resizeOf(core.view(), geom.cols, geom.rows, g.cell_w, g.cell_h, g.tagline_width, g.tagline_height)) |ev| {
- if (cl.posted == null or !std.meta.eql(cl.posted.?, ev.resize)) v.in.post(ev);
- cl.posted = ev.resize;
- } else cl.posted = null;
- if (v.pointer) refreshPresentedPointer(g, v.in);
- runDemo(g, v.in, core);
- if (v.s.test_mode) {
- if (v.s.feed.pump(v.s.gpa, v.in, g) catch return error.TestFeed) v.eof = true;
- }
- }
-};
-
/// `pardes-gui --attach=<where>:<session>`: the window, made as a session's
/// is, a replica client of that session (docs/next-daemon.md, "Phase 6: GUI
/// replica notes"). Its own core, loaded from the session's dump, applies
@@ -1383,6 +1356,10 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
o.image_allocator = allocs.image;
var distrusted: pardes.Addon.Distrusted = .{};
o.distrusted = &distrusted;
+ // Its frame timings, this process's (Pardes.frames).
+ var frames: pardes.FrameStats = .{};
+ o.frames = &frames;
+ frame_probe = &frames;
var joined: replica.Joined = undefined;
var r = replica.join(gpa, &joined, to.path, to.session, o, have, &why, null) orelse Said.no(io, "{s}", .{std.mem.sliceTo(&why, 0)});
@@ -1432,7 +1409,7 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
shell.gview = joined.view;
shell.surface = null;
g.hit_core = core;
- frame_probe = &core.frames;
+ g.frame = null;
link.reset(r, &joined);
client.posted = null;
client.ended = false;
@@ -1452,11 +1429,26 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
var drew = false;
var again = false;
while (!link.quit) {
- core.frames.period_ns = refreshNs(g);
- var own: OwnView = .{ .g = g, .in = &in, .s = &shell, .pointer = drew };
- r.within(&own, OwnView.run);
- client.feed();
- if (own.eof) break;
+ frames.period_ns = refreshNs(g);
+ // The window's own work over the frame it shows (Gui.facts):
+ // the session's font followed, a touchpad's fraction, the
+ // tagline's face, its size posted, the pointer under a frame
+ // that moved, the timedemo's and the test feed's steps.
+ if (syncReplicaFont(g, &core.settings.font, gpa)) link.dirty = true;
+ if (scrollRows(g, &in, gpa)) link.dirty = true;
+ if (fitTaglineFont(g, g.facts.tagline_percent)) link.dirty = true;
+ const geom = windowCells(g);
+ if (resizeOf(&g.facts, geom.cols, geom.rows, g.cell_w, g.cell_h, g.tagline_width, g.tagline_height)) |ev| {
+ if (client.posted == null or !std.meta.eql(client.posted.?, ev.resize)) in.post(ev);
+ client.posted = ev.resize;
+ } else client.posted = null;
+ if (drew) refreshPresentedPointer(g, &in);
+ runDemo(g, &in, core);
+ const eof = test_mode and (shell.feed.pump(gpa, &in, g) catch false);
+ client.feed(g);
+ if (eof) break;
+ if (in.redraw) link.dirty = true;
+ in.redraw = false;
// Its predicted echo judged and caught up, once a frame.
if (r.echoFrame()) link.dirty = true;
drew = false;
@@ -1467,7 +1459,7 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
// A blink, the window's own motion: the last frame again,
// moved on, as the session's own window draws it (pollFrame).
g.now_ns = shell.ownNow();
- shell.presented = renderFrame(g, gpa, core, frame) catch false;
+ shell.presented = renderFrame(g, gpa, frame) catch false;
drew = shell.presented;
};
again = false;
@@ -1475,7 +1467,7 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
// trail) and its blink are on its clock: no unit need come.
const minimized = !test_mode and c.SDL_GetWindowFlags(g.window) & (c.SDL_WINDOW_MINIMIZED | c.SDL_WINDOW_OCCLUDED) != 0;
const moving = !minimized and frontendMoving(g);
- const blink = if (minimized or shell.surface == null) null else blinkNow(g, core.settings.cursor_blink);
+ const blink = if (minimized or shell.surface == null) null else blinkNow(g, g.facts.cursor_blink);
const predicting = r.echo.n > 0 or r.echo.cursor != null or r.echo.nd > 0;
// A latency trace's feed paces the loop, as the session's own
// window's (waitInput): its poll on stdin is the wait, and SDL's,
@@ -1503,9 +1495,10 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_
const timed_out = !got;
while (got) : (got = c.SDL_PollEvent(&sev)) {
if (sev.type == c.SDL_EVENT_USER) continue;
- var one: OwnView = .{ .g = g, .in = &in, .s = &shell, .sev = &sev };
- r.within(&one, OwnView.run);
- client.feed();
+ dispatch(g, &in, &sev);
+ client.feed(g);
+ if (in.redraw) link.dirty = true;
+ in.redraw = false;
if (link.quit) break;
}
client.takeSaid();
@@ -1670,7 +1663,7 @@ const StdinFeed = struct {
_ = c.SDL_GetWindowSizeInPixels(gp.window, &wpw, &wph);
const win_w: f32 = @floatFromInt(@max(wpw, 1));
const win_h: f32 = @floatFromInt(@max(wph, 1));
- handleFinger(&gp.touch, in, finger, win_w, win_h, @floatFromInt(gp.cell_w), @floatFromInt(gp.cell_h), @floatFromInt(gp.tagline_width));
+ handleFinger(gp, &gp.touch, in, finger, win_w, win_h, @floatFromInt(gp.cell_w), @floatFromInt(gp.cell_h), @floatFromInt(gp.tagline_width));
};
}
continue;
@@ -1803,23 +1796,42 @@ fn postKey(in: *Input, key: vaxis.Key, text: []const u8) void {
in.post(ev);
}
+/// The window's input made into events, and where they go: its runner's
+/// core (the session's own window) or its link (a replica client). The
+/// window reads only its frame and the facts beside it (Gui.facts), which
+/// the runner refreshes after each input it applies, as the core is then.
const Input = struct {
core: *pardes.Pardes,
/// The shell whose window this is (views.zig: its view is `gview`).
shell: ?*Shell = null,
/// A replica client's (`runClient`): its inputs go to its link, never
- /// straight to the core, which only reads here.
+ /// straight to the core.
client: ?*Client = null,
quit: bool = false,
+ /// Something the window draws of its own changed (a display's scale, a
+ /// touchpad's fraction): the runner draws again.
+ redraw: bool = false,
fn post(in: *Input, ev: pardes.Event) void {
- if (in.client) |r| return r.post(ev);
+ // A replica client's: fed after the event (Client.feed).
+ if (in.client) |cl| return cl.post(ev);
+ const g = if (in.shell) |s| s.gui else null;
// The window's input is its own view's, a replica client's input
// the session's last or not.
if (in.shell) |s| if (s.core.live != s.gview) {
_ = s.windowView();
};
in.core.update(ev);
+ if (g) |w| pardes.draw.facts(in.core, &w.facts);
+ }
+
+ /// Pane `id`'s first row shown, after the inputs posted: the session's
+ /// own window asks (a wheel's rows stop where the pane does); a replica
+ /// client's speculation may wait on the session, so it never asks.
+ fn scrollOf(in: *const Input, id: usize) ?i32 {
+ if (in.client != null) return null;
+ const pane = in.core.panes[id] orelse return null;
+ return pane.scroll();
}
fn close(in: *Input) void {
@@ -1860,9 +1872,7 @@ fn dispatch(g: *Gui, in: *Input, sev: *const c.SDL_Event) void {
updateDisplayScale(g.window);
// Underlines are drawn into the glyphs a logical pixel thick.
resetGlyphAtlas(g);
- if (in.client) |r| {
- r.link.dirty = true;
- } else in.core.needs_frame = true;
+ in.redraw = true;
},
else => {},
}
@@ -1923,7 +1933,7 @@ fn dispatch(g: *Gui, in: *Input, sev: *const c.SDL_Event) void {
5 => .forward,
else => return,
};
- const mc = pointAt(g, in.core, b.x, b.y);
+ const mc = pointAt(g, b.x, b.y);
var ev = pointerMouse(button, if (b.down) .press else .release, mc, pointerMods());
// Let go past the window's edge (SDL follows a held button out
// of the window: Wayland's implicit grab, X11's capture).
@@ -1951,13 +1961,13 @@ fn dispatch(g: *Gui, in: *Input, sev: *const c.SDL_Event) void {
} else physical_held)
else
physical_held;
- const mc = pointAt(g, in.core, m.x, m.y);
+ const mc = pointAt(g, m.x, m.y);
in.post(.{ .mouse = pointerMouse(held orelse .none, if (held != null) .drag else .motion, mc, pointerMods()) });
},
c.SDL_EVENT_MOUSE_WHEEL => {
const w = sev.wheel;
if (w.y == 0 and w.x == 0) return;
- const mc = pointAt(g, in.core, w.mouse_x, w.mouse_y);
+ const mc = pointAt(g, w.mouse_x, w.mouse_y);
wheelAt(g, in, .{ .x = w.x, .y = w.y, .integer_y = w.integer_y, .mods = pointerMods() }, mc);
},
c.SDL_EVENT_FINGER_DOWN, c.SDL_EVENT_FINGER_MOTION, c.SDL_EVENT_FINGER_UP, c.SDL_EVENT_FINGER_CANCELED => {
@@ -1983,7 +1993,7 @@ fn dispatch(g: *Gui, in: *Input, sev: *const c.SDL_Event) void {
const win_h: f32 = @floatFromInt(@max(ph, 1));
const fcw: f32 = @floatFromInt(g.cell_w);
const fch: f32 = @floatFromInt(g.cell_h);
- handleFinger(&g.touch, in, finger, win_w, win_h, fcw, fch, @floatFromInt(g.tagline_width));
+ handleFinger(g, &g.touch, in, finger, win_w, win_h, fcw, fch, @floatFromInt(g.tagline_width));
},
// The window's font size; a Linux touchpad's pinch stays unused.
c.SDL_EVENT_PINCH_BEGIN, c.SDL_EVENT_PINCH_UPDATE => if (comptime builtin.os.tag == .macos) setFontPx(g, in, Trackpad.pinch(g.px, sev.pinch.scale)),
@@ -2028,14 +2038,14 @@ fn dispatch(g: *Gui, in: *Input, sev: *const c.SDL_Event) void {
for (acts[0..g.deck.feed(pad_input, &acts)]) |act| switch (act) {
.move => |mv| {
const geometry = windowGeometry(g.window);
- const old = mouseCellWithGeometry(g, in.core, g.pad_x, g.pad_y, geometry);
+ const old = mouseCellWithGeometry(g, g.pad_x, g.pad_y, geometry);
const dx = mv.dx * geometry.window_w / geometry.pixel_w;
const dy = mv.dy * geometry.window_h / geometry.pixel_h;
g.pad_x = std.math.clamp(g.pad_x + dx, 0, geometry.window_w - 1);
g.pad_y = std.math.clamp(g.pad_y + dy, 0, geometry.window_h - 1);
c.SDL_WarpMouseInWindow(g.window, g.pad_x, g.pad_y);
g.pointer_present = true;
- const mc = mouseCellWithGeometry(g, in.core, g.pad_x, g.pad_y, geometry);
+ const mc = mouseCellWithGeometry(g, g.pad_x, g.pad_y, geometry);
g.pointer_cell = mc;
if (mc.col == old.col and mc.row == old.row) continue;
const held = heldPointerButton(g);
@@ -2047,7 +2057,7 @@ fn dispatch(g: *Gui, in: *Input, sev: *const c.SDL_Event) void {
.execute => .middle,
.look => .right,
};
- const mc = pointAt(g, in.core, g.pad_x, g.pad_y);
+ const mc = pointAt(g, g.pad_x, g.pad_y);
in.post(.{ .mouse = .{
.button = button,
.kind = if (ck.down) .press else .release,
@@ -2058,7 +2068,7 @@ fn dispatch(g: *Gui, in: *Input, sev: *const c.SDL_Event) void {
} });
},
.wheel => |ticks| {
- const mc = pointAt(g, in.core, g.pad_x, g.pad_y);
+ const mc = pointAt(g, g.pad_x, g.pad_y);
var left = ticks;
while (left != 0) {
left += if (ticks > 0) -1 else 1;
@@ -2078,7 +2088,7 @@ fn dispatch(g: *Gui, in: *Input, sev: *const c.SDL_Event) void {
.cap_n => .{ .cp = 'N', .text = "N" },
.enter => .{ .cp = pardes.Key.enter },
.tab => .{ .cp = pardes.Key.tab },
- .tty_toggle => .{ .cp = in.core.opts.tty_toggle, .ctrl = true },
+ .tty_toggle => .{ .cp = g.tty_toggle, .ctrl = true },
},
}),
.rumble => if (g.gamepad) |pad| {
@@ -2127,7 +2137,7 @@ fn keyDown(in: *Input, sym: c.SDL_Keycode, mod: c.SDL_Keymod) void {
}
fn gridCellAtDimensions(
- core: *const pardes.Pardes,
+ g: *const Gui,
x: f32,
y: f32,
body_w: f32,
@@ -2138,8 +2148,9 @@ fn gridCellAtDimensions(
var point: MouseCell = .{ .col = @intFromFloat(@min(@floor(@max(x, 0) / @max(body_w, 1)), 10_000)), .row = row };
// On the rule over this row, which is where two panes meet if they do.
point.rule_above = row > 0 and @max(y, 0) - @as(f32, @floatFromInt(row)) * @max(body_h, 1) < dp(rule_grab_px);
- if (onGrid(core, x / @max(body_w, 1), y / @max(body_h, 1))) for (core.surface.tagLayers()) |*layer| {
- if (layer.tagHit(x, y, body_w, body_h, tagline_w, @floatFromInt(core.view().row_metrics.tagline_h))) |hit| {
+ const frame = g.frame orelse return point;
+ if (onGrid(&g.facts, x / @max(body_w, 1), y / @max(body_h, 1))) for (frame.tagLayers()) |*layer| {
+ if (layer.tagHit(x, y, body_w, body_h, tagline_w, @floatFromInt(g.facts.row_metrics.tagline_h))) |hit| {
point.tag_hit = hit;
break;
}
@@ -2148,14 +2159,15 @@ fn gridCellAtDimensions(
}
/// Whether a point, in cells, is on the grid.
-fn onGrid(core: *const pardes.Pardes, x: f32, y: f32) bool {
+fn onGrid(f: *const pardes.Facts, x: f32, y: f32) bool {
return std.math.isFinite(x) and std.math.isFinite(y) and x >= 0 and y >= 0 and
- x < @as(f32, @floatFromInt(core.view().screen_w)) and y < @as(f32, @floatFromInt(core.view().screen_h));
+ x < @as(f32, @floatFromInt(f.screen_w)) and y < @as(f32, @floatFromInt(f.screen_h));
}
-fn gridCellAtPixels(g: *const Gui, core: *const pardes.Pardes, x: f32, y: f32) MouseCell {
- var point = gridCellAtDimensions(core, x, y, @floatFromInt(g.cell_w), @floatFromInt(g.cell_h), @floatFromInt(g.tagline_width));
- if (onGrid(core, x / @as(f32, @floatFromInt(g.cell_w)), y / @as(f32, @floatFromInt(g.cell_h)))) for (core.surface.bodyLayers()) |*layer| {
+fn gridCellAtPixels(g: *const Gui, x: f32, y: f32) MouseCell {
+ var point = gridCellAtDimensions(g, x, y, @floatFromInt(g.cell_w), @floatFromInt(g.cell_h), @floatFromInt(g.tagline_width));
+ const frame = g.frame orelse return point;
+ if (onGrid(&g.facts, x / @as(f32, @floatFromInt(g.cell_w)), y / @as(f32, @floatFromInt(g.cell_h)))) for (frame.bodyLayers()) |*layer| {
if (layer.bodyHit(x, y, @floatFromInt(g.cell_w), @floatFromInt(g.cell_h), @floatFromInt(g.tagline_width), @floatFromInt(g.tagline_height))) |hit| {
point.body_hit = hit;
break;
@@ -2168,23 +2180,21 @@ fn gridCellAtPixels(g: *const Gui, core: *const pardes.Pardes, x: f32, y: f32) M
/// part of dispatch after the pointer is placed, so a test can turn it.
fn wheelAt(g: *Gui, in: *Input, w: WheelTurn, mc: MouseCell) void {
if (w.y != 0 and std.math.isFinite(w.y)) {
- const core = in.core;
- const hit: ?usize = for (core.panes, 0..) |slot, i| {
- if (slot == null) continue;
- const r = core.view().rects[i];
+ const hit: ?usize = for (0..pardes.MAX_PANES) |i| {
+ const r = (g.facts.pane(i) orelse continue).rect;
if (mc.col >= r.x and mc.col < r.x + r.w and mc.row >= r.y and mc.row < r.y + r.h) break i;
} else null;
if (g.scroll_pane) |old| if (hit == null or hit.? != old) {
resetScroll(g);
};
if (hit) |id| {
- const pane = core.panes[id].?;
- if (pane.addon != null) {
+ const pane = g.facts.pane(id).?;
+ if (pane.kind == .addon) {
// A kind's (a PDF's strip): the turn as it came, a
// touchpad's fraction of a notch too (pa_mouse.amount).
resetScroll(g);
in.post(.{ .mouse = .{ .button = if (w.y < 0) .wheel_down else .wheel_up, .kind = .press, .col = mc.col, .row = mc.row, .tag_hit = mc.tag_hit, .body_hit = mc.body_hit, .ctrl = w.mods.ctrl, .shift = w.mods.shift, .alt = w.mods.alt, .amount = @abs(w.y) } });
- } else if (!w.mods.shift and pane.isTerminal() and pardes.Term.modes(pane.terminal).wheel) {
+ } else if (!w.mods.shift and pane.program_wheel) {
// The program's (codex, htop, less): every whole turn goes
// to it, no glide, for nothing of ours moves. Shift keeps
// a terminal's wheel pardes's.
@@ -2274,15 +2284,14 @@ fn dispatchTrackpad(g: *Gui, in: *Input, ev: *const c.UITrackpadEvent) void {
c.UI_TRACKPAD_HISTORY => {
if (ev.a == 0 or !std.math.isFinite(ev.a)) return;
const back = ev.a < 0;
- const jumps = &in.core.view().jumps;
- const can_jump = jumps.n > 0 and (if (back) jumps.cur > 0 else jumps.cur + 1 < jumps.n);
+ const can_jump = if (back) g.facts.back else g.facts.forward;
in.post(.{ .command = if (back) "Back" else "Forward" });
if (comptime builtin.os.tag == .macos) if (can_jump) c.ui_macos_trackpad_haptic();
},
c.UI_TRACKPAD_ROTATE => {
- const pane = in.core.panes[in.core.view().active] orelse return;
+ const pane = g.facts.pane(g.facts.active) orelse return;
// Search-step keys never become text in insert/raw mode.
- if (pane.body.mode != .normal) return;
+ if (!pane.normal) return;
var ticks = g.trackpad.rotate(ev.a, ev.phase);
while (ticks != 0) {
in.post(.{ .key = .{ .cp = if (ticks > 0) 'N' else 'n' } });
@@ -2292,13 +2301,13 @@ fn dispatchTrackpad(g: *Gui, in: *Input, ev: *const c.UITrackpadEvent) void {
},
c.UI_TRACKPAD_PRESSURE => {
const previous = g.trackpad.force(ev.a) orelse return;
- const mc = mouseCell(g, in.core, ev.x, ev.y);
+ const mc = mouseCell(g, ev.x, ev.y);
in.post(.{ .mouse = pointerMouse(if (previous == 2) .middle else .left, .release, mc, pointerMods()) });
in.post(.{ .mouse = pointerMouse(.right, .press, mc, pointerMods()) });
in.post(.{ .mouse = pointerMouse(.right, .release, mc, pointerMods()) });
},
c.UI_TRACKPAD_SCROLL => {
- const mc = pointAt(g, in.core, ev.x, ev.y);
+ const mc = pointAt(g, ev.x, ev.y);
// AppKit reports points; the grid is measured in backing pixels.
const geometry = windowGeometry(g.window);
const rows = ev.b * geometry.pixel_h / geometry.window_h / @as(f32, @floatFromInt(g.cell_h));
@@ -2334,22 +2343,22 @@ fn pointerMods() PointerMods {
return .{ .ctrl = (m & c.SDL_KMOD_CTRL) != 0, .shift = (m & c.SDL_KMOD_SHIFT) != 0, .alt = (m & c.SDL_KMOD_ALT) != 0, .super = (m & c.SDL_KMOD_GUI) != 0 };
}
-fn mouseCellWithGeometry(g: *const Gui, core: *const pardes.Pardes, x: f32, y: f32, geometry: WindowGeometry) MouseCell {
+fn mouseCellWithGeometry(g: *const Gui, x: f32, y: f32, geometry: WindowGeometry) MouseCell {
const physical = windowPointToPixels(geometry, x, y);
- return gridCellAtPixels(g, core, physical.x, physical.y);
+ return gridCellAtPixels(g, physical.x, physical.y);
}
-fn mouseCell(g: *const Gui, core: *const pardes.Pardes, x: f32, y: f32) MouseCell {
- return mouseCellWithGeometry(g, core, x, y, windowGeometry(g.window));
+fn mouseCell(g: *const Gui, x: f32, y: f32) MouseCell {
+ return mouseCellWithGeometry(g, x, y, windowGeometry(g.window));
}
/// The pointer at window point (x, y), as an event or the gamepad puts it
/// there: where the window keeps it, and the cell under it.
-fn pointAt(g: *Gui, core: *const pardes.Pardes, x: f32, y: f32) MouseCell {
+fn pointAt(g: *Gui, x: f32, y: f32) MouseCell {
g.pad_x = x;
g.pad_y = y;
g.pointer_present = true;
- const mc = mouseCell(g, core, x, y);
+ const mc = mouseCell(g, x, y);
g.pointer_cell = mc;
return mc;
}
@@ -2363,7 +2372,7 @@ fn hitTest(_: ?*c.SDL_Window, area: [*c]const c.SDL_Point, data: ?*anyopaque) ca
const g: *Gui = @ptrCast(@alignCast(data orelse return c.SDL_HITTEST_NORMAL));
const core = g.hit_core orelse return c.SDL_HITTEST_NORMAL;
if (area == null) return c.SDL_HITTEST_NORMAL;
- const mc = mouseCell(g, core, @floatFromInt(area.*.x), @floatFromInt(area.*.y));
+ const mc = mouseCell(g, @floatFromInt(area.*.x), @floatFromInt(area.*.y));
return if (pardes.tagline.workspaceBlank(core, mc.col, mc.row, mc.tag_hit)) c.SDL_HITTEST_DRAGGABLE else c.SDL_HITTEST_NORMAL;
}
@@ -2377,7 +2386,7 @@ fn heldPointerButton(g: *const Gui) ?pardes.Mouse.Button {
fn refreshPresentedPointer(g: *Gui, in: *Input) void {
if (!g.pointer_present) return;
- const mc = mouseCell(g, in.core, g.pad_x, g.pad_y);
+ const mc = mouseCell(g, g.pad_x, g.pad_y);
const moved = g.pointer_cell == null or g.pointer_cell.?.col != mc.col or g.pointer_cell.?.row != mc.row;
g.pointer_cell = mc;
if (!moved) return;
@@ -2391,7 +2400,7 @@ fn pollGamepad(g: *Gui, in: *Input) void {
const deadzone: f32 = 8000;
const ax: f32 = @floatFromInt(c.SDL_GetGamepadAxis(pad, c.SDL_GAMEPAD_AXIS_RIGHTX));
const ay: f32 = @floatFromInt(c.SDL_GetGamepadAxis(pad, c.SDL_GAMEPAD_AXIS_RIGHTY));
- const old = mouseCellWithGeometry(g, in.core, g.pad_x, g.pad_y, geometry);
+ const old = mouseCellWithGeometry(g, g.pad_x, g.pad_y, geometry);
const speed: f32 = @as(f32, @floatFromInt(g.cell_h)) * 0.4;
const speed_x = speed * geometry.window_w / geometry.pixel_w;
const speed_y = speed * geometry.window_h / geometry.pixel_h;
@@ -2402,7 +2411,7 @@ fn pollGamepad(g: *Gui, in: *Input) void {
g.pointer_present = true;
c.SDL_WarpMouseInWindow(g.window, g.pad_x, g.pad_y);
}
- const mc = mouseCellWithGeometry(g, in.core, g.pad_x, g.pad_y, geometry);
+ const mc = mouseCellWithGeometry(g, g.pad_x, g.pad_y, geometry);
if (g.pointer_present) {
g.pointer_cell = mc;
if (mc.col != old.col or mc.row != old.row) {
@@ -2858,7 +2867,7 @@ fn waitInput(ctx: ?*anyopaque, timeout_ms: u32) void {
// a frame a loop through an edge, else a wake at the next one; none
// while the window is minimized or unfocused. A virtual clock never
// blinks, so goldens hold still.
- const blink = if (s.test_clock != null or minimized or s.surface == null) null else blinkNow(g, s.core.settings.cursor_blink);
+ const blink = if (s.test_clock != null or minimized or s.surface == null) null else blinkNow(g, g.facts.cursor_blink);
const blink_ms: ?c_int = if (blink) |b| (if (b.edge) 1 else if (b.next_ns) |next| @as(c_int, @intCast(@min(std.math.maxInt(c_int), next / std.time.ns_per_ms + 1))) else null) else null;
const blinked: c_int = if (blink_ms) |b| (if (waited < 0) b else @min(waited, b)) else waited;
// The timedemo's next step is a wake too.
@@ -2996,6 +3005,7 @@ fn waitInput(ctx: ?*anyopaque, timeout_ms: u32) void {
}
s.drainQueue();
if (s.gui) |g| pollGamepad(g, &in);
+ if (in.redraw) core.needs_frame = true;
}
/// Detached: no window, asleep until the queue's wake (an SDL user event:
@@ -3041,7 +3051,7 @@ fn pollFrame(ctx: ?*anyopaque) void {
if (due) _ = s.windowView();
}
syncWindowOpacity(g, core);
- core.frames.period_ns = refreshNs(g);
+ frame_probe.?.period_ns = refreshNs(g);
syncTaglineFont(g, core);
if (core.takeFontRequest()) |path| blk: {
const bytes = filesystem.readFile(s.gpa, path) catch {
@@ -3068,7 +3078,7 @@ fn pollFrame(ctx: ?*anyopaque) void {
if ((g.blink_due or frontendMoving(g)) and !core.needs_frame and s.presented) if (s.surface) |frame| {
g.blink_due = false;
g.now_ns = s.ownNow();
- s.presented = renderFrame(g, s.gpa, core, frame) catch false;
+ s.presented = renderFrame(g, s.gpa, frame) catch false;
};
}
@@ -3110,62 +3120,65 @@ fn demoDue(g: *const Gui) ?c_int {
/// through the paths the window's own wheel and keys take, over the
/// focused pane's body; its clock starts at the first loop. Its end
/// ends the session (PARDES_FRAMES has the timings then).
+/// The `.exec` step is the harness's own act on the session (`core`), not
+/// the window's input; every other step reads only what the window shows.
fn runDemo(g: *Gui, in: *Input, core: *pardes.Pardes) void {
- const v = core.view();
const steps = g.demo;
var next = g.demo_next orelse return;
const now = monoNs();
+ const frames = frame_probe.?;
if (g.demo_start_ns == 0) {
g.demo_start_ns = now;
- core.frames.demo_ns = now;
- core.frames.demo = g.demo;
+ frames.demo_ns = now;
+ frames.demo = g.demo;
}
defer g.demo_next = next;
while (next < steps.len and g.demo_start_ns + @as(u64, steps[next].at_ms) * std.time.ns_per_ms <= now) : (next += 1) {
- const r = v.rects[v.active];
+ const r = if (g.facts.pane(g.facts.active)) |pane| pane.rect else pardes.layout.Rect{};
if (steps[next].act != .phase) g.input_seen = true;
switch (steps[next].act) {
.wheel => |notches| {
- core.frames.input(now);
+ frames.input(now);
wheelAt(g, in, .{ .y = @floatFromInt(-notches), .integer_y = -notches }, .{ .col = r.x + r.w / 2, .row = r.y + r.h / 2 });
},
.touch => |lines| {
- core.frames.input(now);
+ frames.input(now);
wheelAt(g, in, .{ .y = -lines }, .{ .col = r.x + r.w / 2, .row = r.y + r.h / 2 });
},
.key => |key| {
- core.frames.input(now);
+ frames.input(now);
in.post(.{ .key = key });
},
.phase => {},
.click => |click| {
- core.frames.input(now);
- const pane = core.panes[v.active] orelse continue;
- const top = core.bodyTop(pane, r);
+ frames.input(now);
+ const pane = g.facts.pane(g.facts.active) orelse continue;
+ const top = r.y + pane.tag_rows;
const row: u16 = top + @as(u16, @intFromFloat(click.at * @as(f32, @floatFromInt(r.h -| pane.tag_rows -| 1))));
const col: u16 = if (click.rail) r.x else r.x + config.GUTTER + 4;
for ([_]pardes.Mouse.Kind{ .press, .release }) |kind| in.post(.{ .mouse = .{ .button = click.button, .kind = kind, .col = col, .row = row } });
},
.rail_wheel => |notches| {
- core.frames.input(now);
+ frames.input(now);
wheelAt(g, in, .{ .y = @floatFromInt(-notches), .integer_y = -notches }, .{ .col = r.x, .row = r.y + r.h / 2 });
},
.paste => |text| {
- core.frames.input(now);
+ frames.input(now);
in.post(.{ .paste = text });
},
.exec => |line| {
- core.frames.input(now);
+ frames.input(now);
var newest: u32 = 0;
for (core.panes) |slot| if (slot) |pane| {
newest = @max(newest, pane.serial);
};
- _ = pardes.exec.executeFrom(core, v.active, line, false);
+ _ = pardes.exec.executeFrom(core, core.view().active, line, false);
// What it opened is what the next steps scroll.
for (core.panes, 0..) |slot, id| if (slot) |pane| if (pane.serial > newest) {
- v.active = id;
+ core.view().active = id;
core.needs_frame = true;
};
+ pardes.draw.facts(core, &g.facts);
},
.end => in.close(),
}
@@ -3265,25 +3278,28 @@ fn syncWindowOpacity(g: *Gui, core: *pardes.Pardes) void {
"background transparency requires a native Wayland or alpha-capable SDL window");
}
-fn present(ctx: ?*anyopaque, surface: *const pardes.Surface) void {
+fn present(ctx: ?*anyopaque, surface: *const pardes.Surface) bool {
const s = shellOf(ctx);
- const core = s.core;
// A replica client draws outside the pump, which marks it there.
- if (s.client != null) core.frames.mark_render = pardes.FrameStats.nowNs();
- const g = s.gui orelse return;
+ if (s.client != null) if (frame_probe) |frames| {
+ frames.mark_render = pardes.FrameStats.nowNs();
+ };
+ const g = s.gui orelse return true;
frame_started_ns = monoNs();
const frame = surface;
s.surface = frame;
+ g.frame = frame;
+ g.facts = frame.facts.*;
g.frame_arrival_ns = monoNs();
g.now_ns = s.ownNow();
- s.presented = renderFrame(g, s.gpa, core, frame) catch |err| blk: {
+ s.presented = renderFrame(g, s.gpa, frame) catch |err| blk: {
log.err("render: {t}", .{err});
break :blk false;
};
// A skipped swapchain image would otherwise hide this input's frame until
// the next event. A few retries only: a minimized window never gets one.
s.skipped_presents = if (s.presented) 0 else s.skipped_presents +| 1;
- if (!s.presented and s.skipped_presents <= 3) core.present_skipped = true;
+ return s.presented or s.skipped_presents > 3;
}
/// The gamepad subsystem, started once the first frame is drawn, as the
@@ -3670,7 +3686,9 @@ const WheelRun = struct {
const r = core.view().rects[core.view().active];
wr.mc = .{ .col = r.x + 10, .row = r.y + r.h / 2 };
core.advance(wr.now_ns);
- _ = try core.render(wr.arena.allocator());
+ const s = try core.render(wr.arena.allocator());
+ wr.g.frame = s;
+ wr.g.facts = s.facts.*;
try wr.frame(gpa, &.{});
return wr;
}
@@ -3697,6 +3715,8 @@ const WheelRun = struct {
if (!wr.core.needs_frame and !frontendMoving(&wr.g)) return;
_ = wr.arena.reset(.retain_capacity);
const s = try wr.core.render(wr.arena.allocator());
+ wr.g.frame = s;
+ wr.g.facts = s.facts.*;
wr.g.now_ns = wr.now_ns;
glideFrame(&wr.g, gpa, s);
wr.core.needs_frame = false;
@@ -3780,17 +3800,19 @@ const settle_land: f32 = 0.02;
fn stepScroll(g: *Gui, core: *pardes.Pardes, gpa: std.mem.Allocator) void {
stepGlide(g, core);
+ // What the wheel's rows moved, read again (Gui.facts).
+ pardes.draw.facts(core, &g.facts);
var in: Input = .{ .core = core };
_ = scrollRows(g, &in, gpa);
+ if (in.redraw) core.needs_frame = true;
}
/// A touchpad's fraction: the picture moved by it, and each whole row it
/// crosses posted to `in` (a replica client's go to its link, applied
/// after its view is parked again). True when the picture moved.
fn scrollRows(g: *Gui, in: *Input, gpa: std.mem.Allocator) bool {
- const core = in.core;
const id = g.scroll_pane orelse return false;
- const pane = core.panes[id] orelse {
+ const pane = g.facts.pane(id) orelse {
resetScroll(g);
return false;
};
@@ -3813,7 +3835,7 @@ fn scrollRows(g: *Gui, in: *Input, gpa: std.mem.Allocator) bool {
if (g.scroll_lag == 0 and g.scroll_notch == 0 and !g.glide.moving()) resetScroll(g);
return false;
}
- const r = core.view().rects[id];
+ const r = pane.rect;
if (r.h <= pane.tag_rows) {
resetScroll(g);
return false;
@@ -3824,7 +3846,7 @@ fn scrollRows(g: *Gui, in: *Input, gpa: std.mem.Allocator) bool {
while (left != 0) {
const down = left > 0;
left += if (down) -1 else 1;
- const was = pane.scroll();
+ const was = in.scrollOf(id);
in.post(.{
.mouse = .{
.button = if (down) .wheel_down else .wheel_up,
@@ -3834,9 +3856,8 @@ fn scrollRows(g: *Gui, in: *Input, gpa: std.mem.Allocator) bool {
.shift = true, // pardes's own scroll, never a program's wheel
},
});
- // A replica client's rows apply after its view is parked again:
- // its scroll has not moved yet.
- if (in.client == null and pane.scroll() == was) {
+ // A replica client's rows may wait on the session: it never asks.
+ if (was != null and in.scrollOf(id) == was) {
resetScroll(g);
return false;
}
@@ -3846,14 +3867,14 @@ fn scrollRows(g: *Gui, in: *Input, gpa: std.mem.Allocator) bool {
// the last one, a fraction of a row off, and the next turn's frame
// jumps from there (against the turn when it reverses).
const moved = st.rows != 0 or st.lag != g.scroll_lag;
- if (moved and in.client == null) core.needs_frame = true;
+ if (moved and in.client == null) in.redraw = true;
g.scroll_lag = st.lag;
g.scroll_rect = r;
- const body_y = core.bodyTop(pane, r);
+ const body_y = r.y + pane.tag_rows;
g.scroll_body_y = body_y;
g.scroll_body_h = r.h -| pane.tag_rows;
- if (st.rows != 0) {
- const s = &core.surface;
+ if (st.rows != 0 and g.frame != null) {
+ const s = g.frame.?;
g.scroll_edge_len = 0;
if (r.w > config.GUTTER and r.h > pane.tag_rows and r.x + r.w <= s.cols) {
const bw = r.w - config.GUTTER;
@@ -4143,9 +4164,9 @@ fn imageScissor(g: *const Gui, place: pardes.Placement) c.SDL_Rect {
fn renderFrame(
g: *Gui,
gpa: std.mem.Allocator,
- core: *pardes.Pardes,
canonical: *const pardes.Surface,
) !bool {
+ const facts = canonical.facts;
// The pictures a pane asks to see as glyph art, drawn into a copy of
// the frame (Art.zig); the rest are textures.
if (g.art_arena == null) g.art_arena = .init(gpa);
@@ -4187,7 +4208,7 @@ fn renderFrame(
const chrome = &surface.chrome;
// G6: what the scroll just done moved the pane's rows by, measured on
// this frame against the last (the glide follows it from there).
- for (core.panes, &g.glide.held) |slot, *held| held.* = if (slot) |pane| pane.context_rows else 0;
+ for (&g.glide.held, 0..) |*held, id| held.* = if (facts.pane(id)) |pane| pane.context_rows else 0;
glideFrame(g, gpa, surface);
var groups: Groups = .{};
const now = g.now_ns;
@@ -4195,7 +4216,7 @@ fn renderFrame(
// While the cursor glides or blinks the cells' cursors are not drawn;
// the focused one is the overlay's quad. One or the other every frame
// (none only at a blink's off half).
- const blink_alpha: f32 = if (blinkNow(g, core.settings.cursor_blink)) |b| b.alpha else 1;
+ const blink_alpha: f32 = if (blinkNow(g, facts.cursor_blink)) |b| b.alpha else 1;
// While a glide moves the text, the caret is its quad, drawn from its
// own springs, not a cell of the moving rows.
const gliding = g.caret.moving();
@@ -4205,10 +4226,12 @@ fn renderFrame(
const caret_alpha: f32 = if (gliding) 0.85 + 0.15 * std.math.clamp(1 - g.caret.remaining(now) / 0.5, 0, 1) else 1;
g.cursor_quad_alpha = if (quad_mode) caret_alpha * blink_alpha else 0;
// The probe's view of this frame's motion (FrameStats.Frame).
- core.frames.scroll = g.glide.follow.offset;
- core.frames.caret = caretRow(g, surface, now) orelse 0;
+ if (frame_probe) |frames| {
+ frames.scroll = g.glide.follow.offset;
+ frames.caret = caretRow(g, surface, now) orelse 0;
+ }
const cursors_shown = !quad_mode;
- var overlay_count = buildOverlay(g, core.settings.pet, core.settings.jump_trail, surface, now, sw, sh);
+ var overlay_count = buildOverlay(g, facts.pet, facts.jump_trail, surface, now, sw, sh);
if (overlay_count != 0 and !g.cells.uploadOverlay(cmd, g.overlay_vertices[0..overlay_count]))
overlay_count = 0;
if (!prepareNativeImages(g, gpa, cmd, surface, &groups, sw, sh)) {
@@ -4222,7 +4245,7 @@ fn renderFrame(
const cells: u32 = @as(u32, surface.cols) * surface.rows;
try g.cover.resize(gpa, cells);
const covered = g.cover.items[0..cells];
- dim.begin(core.settings.inactive_dim, surface.regionList());
+ dim.begin(facts.inactive_dim, surface.regionList());
coverFrame(covered, surface.cols, surface.rows, surface.bodyLayers(), surface.tagLayers(), surface.regionList());
try buildDecor(g, gpa, surface, &groups, layout, win_w, win_h, cursors_shown);
@@ -4324,7 +4347,7 @@ fn renderFrame(
std.debug.assert(cell_next[index] == group.cell_start + group.cell_count);
// The body's context rows, which its scroll leaves where they are.
const scrolling: ?usize = if (g.glide.follow.offset != 0) g.glide.pane else g.scroll_pane;
- const held: u16 = if (scrolling) |id| if (core.panes[id]) |pane| pane.context_rows else 0 else 0;
+ const held: u16 = if (scrolling) |id| if (facts.pane(id)) |pane| pane.context_rows else 0 else 0;
shifted = emitScrollRows(g, instances, cell_total, surface, layout, win_w, win_h, page, held);
@memcpy(instances[cell_total + shifted ..][0..decor_len], g.decor.items);
g.cells.uploadCells(cmd, cell_total + shifted + decor_len, &g.atlas);
@@ -6571,24 +6594,27 @@ test "tagline pointer mapping retains physical grips and carries logical text co
const tag_y = r.y;
const x = @as(f32, @floatFromInt(r.x + pardes.TAG_TEXT_INSET)) * body_w + 3.5 * tag_w;
- const tag = gridCellAtDimensions(core, x, (@as(f32, @floatFromInt(tag_y)) + 0.5) * body_h, body_w, body_h, tag_w);
+ var g = testGui(10, 20, 8, 12);
+ g.frame = &core.surface;
+ g.facts = core.surface.facts.*;
+ const tag = gridCellAtDimensions(&g, x, (@as(f32, @floatFromInt(tag_y)) + 0.5) * body_h, body_w, body_h, tag_w);
try std.testing.expectEqual(pixelCell(x, 10), tag.col);
try std.testing.expectEqual(tag_y, tag.row);
try std.testing.expectEqual(@as(u16, 3), tag.tag_hit.?.col);
try std.testing.expectEqual(pardes.TagKind.pane, tag.tag_hit.?.kind);
- const grip = gridCellAtDimensions(core, @as(f32, @floatFromInt(r.x + config.GUTTER)) * body_w - 0.1, (@as(f32, @floatFromInt(tag_y)) + 0.5) * body_h, body_w, body_h, tag_w);
+ const grip = gridCellAtDimensions(&g, @as(f32, @floatFromInt(r.x + config.GUTTER)) * body_w - 0.1, (@as(f32, @floatFromInt(tag_y)) + 0.5) * body_h, body_w, body_h, tag_w);
try std.testing.expect(grip.tag_hit == null);
try std.testing.expectEqual(r.x + config.GUTTER - 1, grip.col);
const body_y = tag_y + core.panes[core.view().active].?.tag_rows; // a long tag wraps
- const body = gridCellAtDimensions(core, x, (@as(f32, @floatFromInt(body_y)) + 0.5) * body_h, body_w, body_h, tag_w);
+ const body = gridCellAtDimensions(&g, x, (@as(f32, @floatFromInt(body_y)) + 0.5) * body_h, body_w, body_h, tag_w);
try std.testing.expectEqual(pixelCell(x, 10), body.col);
try std.testing.expectEqual(body_y, body.row);
try std.testing.expect(body.tag_hit == null);
// The workspace tag's text starts TAG_TEXT_INSET cells in, as a pane's.
const x_top = @as(f32, @floatFromInt(pardes.TAG_TEXT_INSET)) * body_w + 3.5 * tag_w;
- const topbar = gridCellAtDimensions(core, x_top, 0.5 * body_h, body_w, body_h, tag_w);
+ const topbar = gridCellAtDimensions(&g, x_top, 0.5 * body_h, body_w, body_h, tag_w);
try std.testing.expectEqual(pixelCell(x_top, 10), topbar.col);
try std.testing.expectEqual(@as(u16, 3), topbar.tag_hit.?.col);
try std.testing.expectEqual(pardes.TagKind.workspace, topbar.tag_hit.?.kind);
@@ -6598,11 +6624,12 @@ test "a click at the window's corner lands in the corner cell" {
const core = try pardes.Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 });
defer core.deinit();
var g = testGui(10, 20, 6, 12);
+ pardes.draw.facts(core, &g.facts);
const geometry: WindowGeometry = .{ .window_w = 400, .window_h = 240, .pixel_w = 800, .pixel_h = 480 };
- const last = mouseCellWithGeometry(&g, core, 399.9, 239.9, geometry);
+ const last = mouseCellWithGeometry(&g, 399.9, 239.9, geometry);
try std.testing.expectEqual(@as(u16, 79), last.col);
try std.testing.expectEqual(@as(u16, 23), last.row);
- const first = mouseCellWithGeometry(&g, core, 0, 0, geometry);
+ const first = mouseCellWithGeometry(&g, 0, 0, geometry);
try std.testing.expectEqual(@as(u16, 0), first.col);
try std.testing.expectEqual(@as(u16, 0), first.row);
}
@@ -6796,6 +6823,7 @@ test "a wheel over codex in a terminal reaches its pty as the mouse reports it a
var g = testGui(10, 20, 6, 12);
defer g.glide.deinit(gpa);
var in: Input = .{ .core = core };
+ pardes.draw.facts(core, &g.facts);
var sent: std.ArrayList(u8) = .empty;
defer sent.deinit(gpa);
const Sent = struct {
@@ -6813,6 +6841,7 @@ test "a wheel over codex in a terminal reaches its pty as the mouse reports it a
const mc: MouseCell = .{ .col = r.x + config.GUTTER + 5, .row = core.bodyTop(pane, r) + 3 };
// What codex 0.159's chat sets on start.
core.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?2004h\x1b[>7u\x1b[?1004h\x1b[?1049h\x1b[?1007l\x1b[?1000h\x1b[?1002h\x1b[?1003h\x1b[?1006h" } });
+ pardes.draw.facts(core, &g.facts);
_ = try Sent.take(core, &sent);
// A notch up, then a fast turn of three down: each its report, none
// left behind for a glide.
@@ -6838,12 +6867,14 @@ test "a wheel over codex in a terminal reaches its pty as the mouse reports it a
resetScroll(&g);
// Its sign-in screen: mouse off, alternate scroll on, so arrow keys.
core.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?1006l\x1b[?1003l\x1b[?1002l\x1b[?1000l\x1b[?1007h" } });
+ pardes.draw.facts(core, &g.facts);
_ = try Sent.take(core, &sent);
wheelAt(&g, &in, .{ .y = -1, .integer_y = -1 }, mc);
try std.testing.expectEqualStrings("\x1b[B", try Sent.take(core, &sent));
// Back on the main screen a shell's wheel is ours: a notch to glide,
// nothing to the pty.
core.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?1049l" } });
+ pardes.draw.facts(core, &g.facts);
_ = try Sent.take(core, &sent);
wheelAt(&g, &in, .{ .y = 1, .integer_y = 1 }, mc);
try std.testing.expectEqualStrings("", try Sent.take(core, &sent));
@@ -8088,13 +8119,16 @@ test "trackpad rotation never types search keys into an insert-mode file or raw
var in: Input = .{ .core = core, .client = &client };
var g: Gui = undefined;
g.trackpad = .{};
+ g.facts = .{};
var ev: c.UITrackpadEvent = std.mem.zeroes(c.UITrackpadEvent);
ev.kind = c.UI_TRACKPAD_ROTATE;
ev.a = 20;
const pane = core.panes[core.view().active].?;
pane.body.mode = .insert;
+ pardes.draw.facts(core, &g.facts);
dispatchTrackpad(&g, &in, &ev);
pane.body.mode = .tty;
+ pardes.draw.facts(core, &g.facts);
dispatchTrackpad(&g, &in, &ev);
try std.testing.expectEqual(@as(usize, 0), client.pending.items.len);
ev.kind = c.UI_TRACKPAD_HISTORY;
@@ -8158,6 +8192,8 @@ test "detached trackpad scrolling keeps fractions local and queues whole rows fo
const id = core.view().active;
const r = core.view().rects[id];
var g: Gui = undefined;
+ g.frame = &core.surface;
+ g.facts = core.surface.facts.*;
g.scroll_pane = id;
g.scroll_delta = 0.375;
g.scroll_lag = 0;
diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig
index 71a87f29..5903e448 100644
--- a/dev/tui/tui.zig
+++ b/dev/tui/tui.zig
@@ -624,23 +624,16 @@ const Client = struct {
link: replica.Link,
/// The client's own view drawn on its terminal, outside any step: the
- /// replica's digest stays the session's (views.drawOne). What the host
- /// writes in the core as it presents (a frame skipped, one owed) is put
- /// back, as the frame statistics are this process's.
+ /// replica's digest stays the session's (views.drawOne); the frame
+ /// statistics are this process's (`Shell.frames`).
fn draw(c: *Client, s: *Shell) void {
- const r = c.link.r;
- const core = r.core();
- const skipped = core.present_skipped;
- const needs = core.needs_frame;
- core.frames.mark_start = pardes.FrameStats.nowNs();
- core.frames.mark_update = core.frames.mark_start;
- r.draw(.{ .ctx = s, .f = Shell.present });
- core.frames.mark_render = core.frames.mark_update;
- const drew = core.frames.bytes > 0;
- c.link.owed = core.present_skipped;
- core.frames.record(pardes.FrameStats.nowNs(), false, c.link.owed);
- core.present_skipped = skipped;
- core.needs_frame = needs;
+ const frames = s.frames;
+ frames.mark_start = pardes.FrameStats.nowNs();
+ frames.mark_update = frames.mark_start;
+ c.link.owed = !c.link.r.draw(.{ .ctx = s, .f = Shell.present });
+ frames.mark_render = frames.mark_update;
+ const drew = frames.bytes > 0;
+ frames.record(pardes.FrameStats.nowNs(), false, c.link.owed);
c.link.drawn(drew);
}
};
@@ -696,6 +689,9 @@ pub fn runClient(init: std.process.Init, opts: pardes.Options, path: []const u8,
o.image_allocator = allocs.image;
var distrusted: pardes.Addon.Distrusted = .{};
o.distrusted = &distrusted;
+ // Its frame timings, this process's (Pardes.frames).
+ var frames: pardes.FrameStats = .{};
+ o.frames = &frames;
var joined: replica.Joined = undefined;
var r = replica.join(gpa, &joined, path, session, o, have, &why, null) orelse Said.no(io, "{s}", .{std.mem.sliceTo(&why, 0)});
@@ -729,6 +725,7 @@ pub fn runClient(init: std.process.Init, opts: pardes.Options, path: []const u8,
.gpa = gpa,
.lsp_gpa = allocs.lsp,
.core = r.core(),
+ .frames = &frames,
.prompt_rcs = undefined,
.loop = &loop,
.frame = &frame_arena,
@@ -768,11 +765,8 @@ pub fn runClient(init: std.process.Init, opts: pardes.Options, path: []const u8,
// The tty's own motions (its glide, a jump's trail): the last
// frame again, moved on, as the session's terminal draws them
// (`ownFrame`), not rendered again. One the terminal's answer
- // holds is skipped (the next tick's moves on): nothing of it
- // is written in the core, as `Client.draw` puts it back.
- const skipped = r.core().present_skipped;
- Shell.present(&sh, &r.core().surface);
- r.core().present_skipped = skipped;
+ // holds is skipped (the next tick's moves on).
+ _ = Shell.present(&sh, &r.core().surface);
link.again += 1;
}
// Idle, its frame drawn: the next key needs no copy taken.
@@ -982,6 +976,9 @@ fn localSession(
options.image_allocator = allocs.image;
options.tree_sitter_allocator = allocs.tree_sitter;
options.frame_allocator = allocs.frame;
+ // Its frame timings, the terminal's to write as it draws (Pardes.frames).
+ var frames: pardes.FrameStats = .{};
+ options.frames = &frames;
host_io.startWorkers(allocs);
defer host_io.stopWorkers();
@@ -1010,6 +1007,7 @@ fn localSession(
.gpa = gpa,
.lsp_gpa = allocs.lsp,
.core = core,
+ .frames = &frames,
.prompt_rcs = &prompt_rcs,
.loop = loop,
.frame = &frame_arena,
@@ -1202,6 +1200,9 @@ const Shell = struct {
gpa: std.mem.Allocator,
lsp_gpa: std.mem.Allocator,
core: *pardes.Pardes,
+ /// Its runner's frame timings (Pardes.frames): written as it draws and
+ /// takes input, never through the core.
+ frames: *pardes.FrameStats,
prompt_rcs: *const host_io.Shell.PromptFiles,
loop: *Loop,
/// The terminal (none in tests), and the view it shows: a second
@@ -1255,6 +1256,9 @@ const Shell = struct {
took_input: bool = false,
took_output: bool = false,
held: ?Msg = null,
+ /// A frame of the tty's own motions was held (`ownFrame`): the core's
+ /// next is owed too (`presentFrame`).
+ own_skipped: bool = false,
/// This process a replica client of a session elsewhere (`runClient`):
/// its inputs go to the replica, never straight to the core.
client: ?*Client = null,
@@ -1290,7 +1294,7 @@ const Shell = struct {
const isolated_vtable: host_io.Host.VTable = .{
.wait_input = waitInput,
.now = clockNow,
- .present = present,
+ .present = presentFrame,
.post_present = postPresent,
.poll_frame = ownFrame,
};
@@ -1298,7 +1302,7 @@ const Shell = struct {
const vtable: host_io.Host.VTable = .{
.wait_input = waitInput,
.now = clockNow,
- .present = present,
+ .present = presentFrame,
.post_present = postPresent,
.poll_frame = pollFrame,
.watched = watched,
@@ -1689,11 +1693,11 @@ const Shell = struct {
// answers it (FrameStats): when the loop takes it in.
switch (event) {
.key_press => {
- core.frames.input(pardes.FrameStats.nowNs());
+ s.frames.input(pardes.FrameStats.nowNs());
s.input_seen = true;
},
.mouse => |m| if (m.type == .press) {
- core.frames.input(pardes.FrameStats.nowNs());
+ s.frames.input(pardes.FrameStats.nowNs());
s.input_seen = true;
},
.paste, .paste_start, .winsize => s.input_seen = true,
@@ -1903,7 +1907,9 @@ const Shell = struct {
/// again, moved on, when the core has none to draw.
fn ownFrame(ctx: ?*anyopaque) void {
const s = of(ctx);
- if (s.moving() and !s.core.needs_frame and s.core.surface.cells.len != 0) present(ctx, &s.core.surface);
+ if (s.moving() and !s.core.needs_frame and s.core.surface.cells.len != 0) {
+ if (!present(ctx, &s.core.surface)) s.own_skipped = true;
+ }
}
fn pollFrame(ctx: ?*anyopaque) void {
@@ -1929,16 +1935,22 @@ const Shell = struct {
}
}
- fn present(ctx: ?*anyopaque, canonical: *const pardes.Surface) void {
+ /// The core's frame (Host.present): owed too when a frame of the
+ /// tty's own motions (`ownFrame`) was held since the last.
+ fn presentFrame(ctx: ?*anyopaque, canonical: *const pardes.Surface) bool {
const s = of(ctx);
- const sc = s.term() orelse return;
+ const shown = present(ctx, canonical);
+ defer s.own_skipped = false;
+ return shown and !s.own_skipped;
+ }
+
+ fn present(ctx: ?*anyopaque, canonical: *const pardes.Surface) bool {
+ const s = of(ctx);
+ const sc = s.term() orelse return true;
const vx = &sc.vx;
// The last frame is not answered yet: this one stays owed, and the
// answer's wake draws the state as it is then.
- if (sc.feed.ack.holds(@intCast(std.Io.Clock.awake.now(s.io).nanoseconds), s.io)) {
- s.core.present_skipped = true;
- return;
- }
+ if (sc.feed.ack.holds(@intCast(std.Io.Clock.awake.now(s.io).nanoseconds), s.io)) return false;
_ = s.frame.reset(.retain_capacity);
const tz_cells = tracy.zone(@src(), "surface->vaxis");
const win = vx.window();
@@ -1949,10 +1961,10 @@ const Shell = struct {
const cell_h = terminalCellPixels(vx.screen.height_pix, vx.screen.height, 16);
const arted = sc.art.frame(s.gpa, s.frame.allocator(), canonical, vx.caps.kitty_graphics, cell_h) catch canonical;
sc.glide.frame(s.gpa, arted, now, null, null);
- s.core.frames.scroll = @round(sc.glide.follow.offset);
+ s.frames.scroll = @round(sc.glide.follow.offset);
const glided = glideRows(s.frame.allocator(), arted, &sc.glide) catch arted;
const truecolor = vx.caps.rgb or colortermTruecolor();
- const trail_on = s.core.settings.jump_trail and truecolor;
+ const trail_on = canonical.facts.jump_trail and truecolor;
const shown = trailCells(s.frame.allocator(), glided, &sc.trail, trail_on, now) catch glided;
paintCells(win, shown.cells, shown.cols, shown.rows);
if (s.client) |c| if (c.link.notice_len > 0) noticeLine(win, c.link.notice(), shown.cols, shown.rows);
@@ -2038,10 +2050,11 @@ const Shell = struct {
vx.render(sc.tty.writer()) catch {};
// The frame's cost to the terminal (FrameStats.Frame.bytes): what
// vaxis's diff of the cells wrote.
- s.core.frames.bytes +|= @intCast(@min(std.math.maxInt(u32), sc.tty.tty_writer.pos + sc.tty.writer().end -| before));
+ s.frames.bytes +|= @intCast(@min(std.math.maxInt(u32), sc.tty.tty_writer.pos + sc.tty.writer().end -| before));
if (sc.tty.tty_writer.pos + sc.tty.writer().end != before) sc.feed.ack.ask(sc.tty.writer(), @intCast(std.Io.Clock.awake.now(s.io).nanoseconds));
s.drawn_ns = @intCast(std.Io.Clock.awake.now(s.io).nanoseconds);
tz_render.end();
+ return true;
}
fn postPresent(ctx: ?*anyopaque) void {
@@ -3016,6 +3029,7 @@ test "TTY queued results reject old PTY generations and LSP request IDs" {
.gpa = gpa,
.lsp_gpa = gpa,
.core = core,
+ .frames = core.frames,
.prompt_rcs = undefined,
.loop = undefined,
.frame = undefined,
@@ -3061,6 +3075,7 @@ test "TTY worker setup failures finish matching LSP and pipe requests" {
.gpa = failing.allocator(),
.lsp_gpa = failing.allocator(),
.core = core,
+ .frames = core.frames,
.prompt_rcs = undefined,
.loop = undefined,
.frame = undefined,
diff --git a/runtime/macos.zig b/runtime/macos.zig
index 9475eb78..3e9c7b9b 100644
--- a/runtime/macos.zig
+++ b/runtime/macos.zig
@@ -1251,7 +1251,7 @@ fn tagCursorCovered(core: *const pardes.Pardes) bool {
return false;
}
-fn presentFrame(ctx: ?*anyopaque, surface: *const pardes.Surface) void {
+fn presentFrame(ctx: ?*anyopaque, surface: *const pardes.Surface) bool {
const st = hostState(ctx);
const tz = tracy.zone(@src(), "presentFrame");
defer tz.end();
@@ -1266,7 +1266,7 @@ fn presentFrame(ctx: ?*anyopaque, surface: *const pardes.Surface) void {
st.gpa.alloc(Cell, count)
else
st.gpa.realloc(st.cells, count);
- st.cells = resized catch return;
+ st.cells = resized catch return true;
}
}
st.frame_len = count;
@@ -1279,6 +1279,7 @@ fn presentFrame(ctx: ?*anyopaque, surface: *const pardes.Surface) void {
}
blankTagCells(st.cells[0..count], surface.cols, surface.rows, surface.cells, &surface.tag_layers);
collectImages(st, surface);
+ return true;
}
fn collectImages(st: *State, surface: *const pardes.Surface) void {
diff --git a/test/replicas.zig b/test/replicas.zig
index d9834209..857dcd75 100644
--- a/test/replicas.zig
+++ b/test/replicas.zig
@@ -467,49 +467,51 @@ const Client = struct {
script: Script = .{},
/// gui.zig `Client.posted`: a size posted once while it waits.
posted: ?@FieldType(pardes.Event, "resize") = null,
+ /// What its last frame showed beside the cells (gui.zig `Gui.facts`),
+ /// and its frame timings (Pardes.frames), its own.
+ facts: pardes.Facts = .{},
+ frames: pardes.FrameStats = .{},
resizes: u32 = 0,
- fn present(ctx: ?*anyopaque, _: *const pardes.Surface) void {
+ fn present(ctx: ?*anyopaque, surface: *const pardes.Surface) bool {
const cl: *Client = @ptrCast(@alignCast(ctx.?));
cl.drew = true;
+ cl.facts = surface.facts.*;
+ return true;
}
/// tui.zig `Client.draw` (gui.zig's is the same): its own view drawn
- /// outside any step, what presenting writes in the core put back.
+ /// outside any step, its timings its own.
fn draw(cl: *Client) void {
const r = cl.r.?;
- const core = r.core();
- const skipped = core.present_skipped;
- const needs = core.needs_frame;
- core.frames.mark_start = pardes.FrameStats.nowNs();
- core.frames.mark_update = core.frames.mark_start;
+ cl.frames.mark_start = pardes.FrameStats.nowNs();
+ cl.frames.mark_update = cl.frames.mark_start;
cl.drew = false;
- r.draw(.{ .ctx = cl, .f = present });
- core.frames.mark_render = core.frames.mark_update;
- cl.link.owed = core.present_skipped;
- core.frames.record(pardes.FrameStats.nowNs(), false, cl.link.owed);
- core.present_skipped = skipped;
- core.needs_frame = needs;
+ cl.link.owed = !r.draw(.{ .ctx = cl, .f = present });
+ cl.frames.mark_render = cl.frames.mark_update;
+ cl.frames.record(pardes.FrameStats.nowNs(), false, cl.link.owed);
cl.link.drawn(cl.drew);
}
- /// gui.zig `OwnView.run` over its own view (`Replica.within`): the
+ /// gui.zig's client pass over the frame it shows (Gui.facts): the
/// window's size against the view's, a resize posted when they differ.
- fn own(cl: *Client, core: *pardes.Pardes) anyerror!void {
- const v = core.view();
+ fn own(cl: *Client) void {
+ const v = &cl.facts;
const metrics: pardes.RowMetrics = .{ .body_w = 9, .body_h = 18, .tagline_w = 9, .tagline_h = 18 };
if (cl.cols == v.screen_w and cl.rows == v.screen_h and v.cell_pixels.w == 9 and v.cell_pixels.h == 18 and std.meta.eql(metrics, v.row_metrics)) return;
cl.resize = .{ .resize = .{ .cols = cl.cols, .rows = cl.rows, .cell_pixels = .{ .w = 9, .h = 18 }, .row_metrics = metrics } };
}
- /// The window's own pass over its view, and what it posted fed.
+ /// The window's own pass over its frame, and what it posted applied.
fn within(cl: *Client) void {
if (cl.kind != .window) return;
- cl.r.?.within(cl, own);
+ cl.own();
if (cl.resize) |ev| {
if (cl.posted == null or !std.meta.eql(cl.posted.?, ev.resize)) {
cl.link.input(ev);
cl.resizes += 1;
+ const r = cl.r.?;
+ if (r.core().live == r.view) pardes.draw.facts(r.core(), &cl.facts);
}
cl.posted = ev.resize;
} else cl.posted = null;
diff --git a/test/rollback_bench.zig b/test/rollback_bench.zig
index 796f7135..d750871e 100644
--- a/test/rollback_bench.zig
+++ b/test/rollback_bench.zig
@@ -99,7 +99,7 @@ fn build(s: Session, dir: []const u8, a: std.mem.Allocator) !*pardes.Pardes {
};
if (nopened == 0) return error.NothingOpened;
for (0..s.edits) |e| {
- core.active = opened[e % nopened];
+ core.view().active = opened[e % nopened];
key(core, 'i', "i");
key(core, 'x', "x");
key(core, pardes.Key.escape, "");