diff options
Diffstat (limited to 'anim/src/loupe.zig')
| -rw-r--r-- | anim/src/loupe.zig | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/anim/src/loupe.zig b/anim/src/loupe.zig index 99dae71..623e966 100644 --- a/anim/src/loupe.zig +++ b/anim/src/loupe.zig @@ -40,7 +40,14 @@ pub const Loupe = struct { stage: *const Stage, /// What it opens from: a register, by name; or a pointer field (its /// address) of the loupe it hangs under. - from: union(enum) { register: []const u8, field: struct { loupe: *const Loupe, at: u64 } }, + /// Or the bytes of a dump's row (`at`, a field the view publishes as a + /// `dump_run`), opening on `fields` (the region it reads them as): a + /// struct the debug info does not type (malloc's tcache), named `name`. + from: union(enum) { + register: []const u8, + field: struct { loupe: *const Loupe, at: u64 }, + row: struct { at: u64, name: []const u8, note: []const u8, fields: hexdump.Fields }, + }, /// 0 to 1 as it opens (`time.loupe.open`) and as it closes (`close`). opening: anim.Value = undefined, closing: anim.Value = undefined, @@ -85,6 +92,14 @@ pub const Loupe = struct { target = (Recording.word(moment, field.at, 8) catch null) orelse return null; right = parent.box.x + 120; }, + .row => |row| { + const px = ties.find(.{ .dump_run = row.at }) orelse return null; + const back = u.at.xf.invert(); + const a = back.apply(.{ px[0], px[1] }); + const b = back.apply(.{ px[2], px[3] }); + pointer = .{ .x = a[0], .y = a[1], .w = b[0] - a[0], .h = b[1] - a[1] }; + target = row.fields.base; + }, } if (target == 0) return null; // shortcut: it keeps to the stage and does not yet move past the current marks or a changed row; the scene picks a pointer whose loupe covers neither. @@ -135,6 +150,10 @@ pub const Loupe = struct { x += v.width(.mono, size, name) + 6; }, .field => |field| x = v.address(x, base, field.at, .{ .ink = ui.rgb(rows.ink(rows.regionOf(moment, field.at))) }) + 6, + .row => |row| { + v.text(.mono, size, x, base, row.name, t.dim); + x += v.width(.mono, size, row.name) + 6; + }, } x = v.arrow(x, m.tag / 2, .points) + 8; _ = v.address(x, base, p.target, .{ .ink = ui.rgb(p.ink) }); @@ -146,16 +165,17 @@ pub const Loupe = struct { .rodata => "read-only", .none => "", }; - const note = if (object) |o| v.print("{s} \u{00b7} {s}, {d} bytes", .{ region, if (o.name.len > 0) o.name else "a struct", o.type.record.size }) else region; + const note = if (l.from == .row) l.from.row.note else if (object) |o| v.print("{s} \u{00b7} {s}, {d} bytes", .{ region, if (o.name.len > 0) o.name else "a struct", o.type.record.size }) else region; v.text(.sans, theme.size.sans.micro, b.w - 10 - v.width(.sans, theme.size.sans.micro, note), base, note, t.dim); // Its rows, typed where the recording types them, its own pointers as arcs at full ink. const top = m.tag + m.pad; v.clip(.{ .x = 0, .y = m.tag, .w = b.w, .h = b.h - m.tag }); - hexdump.drawArcs(v, now, 0, top, p.first, k.rows, .{ .things = things }, true, .{ m.tag, b.h - m.pad }); + // By the scene's fields: the rows that hold them, the rest `more`. + if (l.from == .row) hexdump.fielded(.{ .u = v, .rows = k.rows, .box = b }, now, top, l.from.row.fields) else hexdump.drawArcs(v, now, 0, top, p.first, k.rows, .{ .things = things }, true, .{ m.tag, b.h - m.pad }); v.unclip(); // Its target, framed bright: each field of the struct, or the word. const framed = std.math.clamp((since - time.stem - time.frame) / time.frame, 0, 1); - if (framed > 0) { + if (framed > 0 and l.from != .row) { const row_y = top + @as(f32, @floatFromInt((p.target - p.first) / 16)) * m.row; const shift = rows.addressRoom(p.first + 16 * (k.rows - 1)); const w = v.faded(framed); |
