diff options
Diffstat (limited to 'anim/src/calls.zig')
| -rw-r--r-- | anim/src/calls.zig | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/anim/src/calls.zig b/anim/src/calls.zig index 5eef946..d78c26c 100644 --- a/anim/src/calls.zig +++ b/anim/src/calls.zig @@ -127,8 +127,8 @@ pub const Tree = struct { } } - /// Its view: the backtrace, the waiting path read as rows, newest on - /// top, with each call's arguments (`n=4`) and where it is. + /// Its view: the backtrace, the waiting path read as rows, newest at + /// the bottom, with each call's arguments (`n=4`) and where it is. fn backtrace(k: *const Tree, f: *sk.Frame, at: anim.Placed) void { const box = k.stage.box(at, .view); const cm = theme.metric.context; @@ -143,10 +143,12 @@ pub const Tree = struct { var buf: [24]context.Frame = undefined; const chain = context.frames(rec, moment, &buf); const room = theme.layout.rowsIn(box.h); - const body = u.panel(box.w, box.h, "backtrace", .{ .note = if (chain.len > room) u.print("the calls waiting \u{00b7} newest on top \u{00b7} {d} more", .{chain.len - room}) else "the calls waiting \u{00b7} newest on top" }); + const body = u.panel(box.w, box.h, "backtrace", .{ .note = u.print("the calls waiting \u{00b7} {s}", .{context.newestAtBottom(u, chain.len, room)}) }); const open = rec.stack(f.scratch, moment); - for (chain[0..@min(chain.len, room)], 0..) |frame, i| { - const y = body.y + cm.pad + @as(f32, @floatFromInt(i)) * cm.row; + // Newest at the bottom, as the tree grows down beside it; the oldest go from the top. + const shown = @min(chain.len, room); + for (chain[0..shown], 0..) |frame, i| { + const y = body.y + cm.pad + @as(f32, @floatFromInt(shown - 1 - i)) * cm.row; const name = ui.symbol(u, rec.strings.get(frame.pc) orelse u.print("{x}", .{frame.pc})); // The call this frame is, by its place on the chain: its arguments. rows.callRow(u, y, box.w, i, name, context.callArguments(u, rec, open, i, frame.pc), context.frameWhere(u, rec, now.marked(), i, frame.pc), i == 0); |
