From dc3b58781420be6070fca896e55776bc27db905d Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 20:16:54 -0300 Subject: canim: a scene from a real program: SQLite's row on its way to disk Three inserts stopped at sqlite3BtreeInsert with their payloads read off the caller's stack, the commit's backtrace from unixWrite up to main, the pwrite64 crossing into the kernel, and page 2 as the kernel took it: its header, its cell pointers and the three rows, read by field. The scene is built only where SQLite's source is (-Dsqlite=DIR); its recording is 181 moments, 95 KB. What a real program asked of the blocks: a dump read by the fields a scene gives it, with the rows between collapsed; addresses of twelve digits and line numbers of six; the backtrace as a lens's drawing; a continue's motion (shared frames slide, a far window fades); memory drawn only where the stop read it. In the kernel lens a register is framed as carrying an argument only while it holds it at the stop shown, and an allocator row is read only where an allocation follows the word. Co-Authored-By: Claude Fable 5.2 --- anim/src/source.zig | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'anim/src/source.zig') diff --git a/anim/src/source.zig b/anim/src/source.zig index 0bba714..6b693a4 100644 --- a/anim/src/source.zig +++ b/anim/src/source.zig @@ -42,7 +42,12 @@ pub const Source = struct { // 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 first = std.math.lerp(windows[0], windows[1], cursors.glide(going)); + // Further than two windows (a large file, another function far + // off): what leaves has left before what replaces it arrives; a + // scroll through thousands of lines would be a blur, and say nothing. + const far = @abs(windows[1] - windows[0]) > 2 * @as(f32, @floatFromInt(fit)); + const first = if (far) windows[if (going >= 0.5) 1 else 0] else std.math.lerp(windows[0], windows[1], cursors.glide(going)); + const lit = if (far and going < 1) u.faded(@abs(2 * going - 1)) else u; const from: u32 = @intFromFloat(@floor(first)); const last: u32 = @min(from + @as(u32, @intCast(context.rowsOf(box))), rec.line_count); const shown_first: u32 = @intFromFloat(windows[if (going >= 0.5) 1 else 0]); @@ -73,11 +78,13 @@ pub const Source = struct { } } const mark_y = top + (mark_at - first) * m.row; + // The numbers of the two windows, as wide as the widest needs. + const widen = rows.numberRoom(@min(@as(u32, @intFromFloat(@max(windows[0], windows[1]))) + @as(u32, @intCast(context.rowsOf(box))), rec.line_count)); context.clipBody(u, box); defer u.unclip(); // The plaque over the number. Fire: on the line about to run its // edges go out and come back, once, and nothing else moves. - 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, now.fires(.source)); + 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. @@ -99,7 +106,7 @@ pub const Source = struct { const span = text.lines[line - 1]; const k = std.mem.indexOfScalar(u32, trail[0..found], line); const on = shows >= 0.5 and line == mark_line; - rows.line(u, y, box.w, line, text.bytes[span[0]..span[1]], text.styles[span[0]..span[1]], if (on) .marked else if (k) |n| .{ .trail = n } else .plain); + rows.line(lit, y, box.w, line, widen, text.bytes[span[0]..span[1]], text.styles[span[0]..span[1]], if (on) .marked else if (k) |n| .{ .trail = n } else .plain); } // The source is read at a run; at a sprint it is veiled too. context.veiled(u, box, now.sprint_veil); -- cgit v1.3