From 378379807fb4cd751e90808c8363caddb365bcd8 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 11 Nov 2026 06:49:10 -0300 Subject: canim: nothing changes in one frame; the map's space is used; the heap scene at its storyboard's length The motion check counts a third of the one-frame changes it did: the minimap's changes fade, and a register's value, a flag, a role, a pin's names, a tag's note, a backtrace row, a call tree's node and a dump row crossfade where they changed at once. What still fires is named in the README; an encoder's keyframe and the gallery's cuts are exempt by name. No caption stands over twelve seconds or under its reading time. The heap scene is 78 s: what the storyboard does not narrate runs, and each free's line cascades onto its call row (line stepping stops at a breakpoint for that). On the map, leftover space holds the stack continued, dumps round what the registers and the stack point at, open loupes and the key: between 1% and 13% of a map is page, where it was 14% to 42%. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa --- anim/src/source.zig | 56 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 18 deletions(-) (limited to 'anim/src/source.zig') diff --git a/anim/src/source.zig b/anim/src/source.zig index 3843825..0705f5b 100644 --- a/anim/src/source.zig +++ b/anim/src/source.zig @@ -32,21 +32,29 @@ pub const Source = struct { /// In a `descent`: while the pc is in code without source, the line it /// called from waits, ringed, and the tag says where the pc is. descent: bool = false, + /// Which box of its stage it is in: on the map the source may go on in `source_more`. + part: @import("stage.zig").Part = .source, pub fn draw(p: *const Source, f: *sk.Frame, placed: anim.Placed) void { - const box = p.stage.box(placed, .source); + const box = p.stage.box(placed, p.part); + if (box.h < m.tag + m.row) return; const u = context.at(f, placed, box); const rec = p.cursor.rec; const now = p.cursor.now(placed); const text = prepared(rec.source, rec.file) orelse return; + // Its window, and on the map the lines of both its boxes (`continued`): this one from `skip` lines in. + const head = theme.layout.rowsIn(p.stage.box(placed, .source).h); + const tail = theme.layout.rowsIn(p.stage.box(placed, .source_more).h); const fit: u32 = @intCast(theme.layout.rowsIn(box.h)); + const span_fit: u32 = @intCast(head + tail); + const skip: f32 = if (p.part == .source_more) @floatFromInt(head) else 0; // The mark: leaving the line of one moment for that of the next. const was = rec.own[now.marks[0]]; const here = rec.own[now.marks[1]]; // The window: where the line it is on has it, and (as the mark // moves on) gliding to where the next one does. It never cuts. const going = now.advancing(); - const windows = [2]f32{ @floatFromInt(rec.viewFirst(fit, was)), @floatFromInt(rec.viewFirst(fit, here)) }; + const windows = [2]f32{ @as(f32, @floatFromInt(rec.viewFirst(span_fit, was))) + skip, @as(f32, @floatFromInt(rec.viewFirst(span_fit, here))) + skip }; // Farther than its own height (another function far off): what // leaves has left before what replaces it arrives; a scroll of more // lines than the window shows would be a blur, and say nothing. @@ -64,9 +72,9 @@ pub const Source = struct { var notes: [2][]const u8 = undefined; for (now.marks, ¬es) |mk, *note| note.* = if (p.descent and !rec.sourced(mk) and rec.own[mk] != 0) u.print("{s} waits at line {d} \u{00b7} the pc is in {s}", .{ context.frameName(u, rec, rec.register(firstOwn(rec, mk), "rip")), rec.own[mk], whereIs(u, rec, mk) }) else lines_note; const swap = !std.mem.eql(u8, notes[0], notes[1]) and (notes[0].ptr != lines_note.ptr or notes[1].ptr != lines_note.ptr) and now.walking(); - const body = u.panel(box.w, box.h, rec.file, .{ .focus = p.focus, .note = if (swap) "" else if (waits) notes[if (going >= 0.5) 1 else 0] else lines_note }); + const body = u.panel(box.w, box.h, if (p.part == .source_more) u.print("{s}, continued", .{rec.file}) else rec.file, .{ .focus = p.focus, .note = if (swap) "" else if (waits) notes[if (going >= 0.5) 1 else 0] else lines_note }); if (swap) { - const c = std.math.clamp((now.time - now.plan.advance + 12.0 / 60.0) / (12.0 / 60.0), 0, 1); + const c = now.renaming(); u.faded(1 - c).tagNote(box.w, notes[0]); u.faded(c).tagNote(box.w, notes[1]); } @@ -109,28 +117,40 @@ pub const Source = struct { } else if (shows > 0) u.faded(shows).current(.{ .x = theme.stroke.rule, .y = mark_y, .w = box.w - 2 * theme.stroke.rule, .h = m.row }, theme.metric.plaque.line + widen, now.fires(.source)); if (shows >= 1 and mark_y >= body.y and mark_y + m.row <= box.h) ties.anchor(u, .source, .{ .x = 0, .y = mark_y, .w = box.w, .h = m.row }); - // The trail: the last three other lines it was on. It shifts without animation. - const on_line = rec.own[now.marked()]; - var trail: [3]u32 = @splat(0); - var found: usize = 0; - var back = now.marked(); - while (back > 0 and found < trail.len) { - back -= 1; - const l = rec.own[back]; - if (l == 0 or l == on_line or std.mem.indexOfScalar(u32, trail[0..found], l) != null) continue; - trail[found] = l; - found += 1; + // The trail: the last three other lines it was on, as the mark left + // them and as it finds them: a bar that moves crossfades with the advance. + var trails: [2][3]u32 = @splat(@splat(0)); + var founds = [2]usize{ 0, 0 }; + for (now.marks, &trails, &founds) |mk, *trail, *found| { + const on_line = rec.own[mk]; + var back = mk; + while (back > 0 and found.* < trail.len) { + back -= 1; + const l = rec.own[back]; + if (l == 0 or l == on_line or std.mem.indexOfScalar(u32, trail[0..found.*], l) != null) continue; + trail[found.*] = l; + found.* += 1; + } } - map.window(.source, shown_first, @min(shown_first + fit - 1, rec.line_count)); + const lines_of = struct { + fn of(at: f32, n: u32, lines: u32) [2]u64 { + const a: u32 = @intFromFloat(at); + return .{ a, @min(a + n - 1, lines) }; + } + }.of; + map.window(.source, lines_of(windows[1], fit, rec.line_count), lines_of(windows[0], fit, rec.line_count), cursors.glide(going)); var line = @max(from, 1); while (line <= last) : (line += 1) { const y = top + (@as(f32, @floatFromInt(line)) - first) * m.row; map.row(.source, line, u, .{ .x = 0, .y = y, .w = box.w, .h = m.row }); const span = text.lines[line - 1]; - const k = std.mem.indexOfScalar(u32, trail[0..found], line); + const ks = [2]?usize{ std.mem.indexOfScalar(u32, trails[0][0..founds[0]], line), std.mem.indexOfScalar(u32, trails[1][0..founds[1]], line) }; + const k = if (going >= 0.5) ks[1] else ks[0]; const on = shows >= 0.5 and line == mark_line; - rows.line(lit, y, box.w, line, widen, text.bytes[span[0]..span[1]], text.styles[span[0]..span[1]], if (on and !waits) .marked else if (k) |n| .{ .trail = n } else .plain); + const fading = !std.meta.eql(ks[0], ks[1]) and going > 0 and going < 1; + rows.line(lit, y, box.w, line, widen, text.bytes[span[0]..span[1]], text.styles[span[0]..span[1]], if (on and !waits) .marked else if (fading) .plain else if (k) |n| .{ .trail = n } else .plain); + if (fading and !(on and !waits)) for (ks, [2]f32{ 1 - going, going }) |kk, amount| if (kk) |n| lit.faded(amount).trail(theme.stroke.rule, y, n); } // The source is read at a run; at a sprint it is veiled too. context.veiled(u, box, now.sprint_veil); -- cgit v1.3