summaryrefslogtreecommitdiff
path: root/anim/src/disasm.zig
diff options
context:
space:
mode:
Diffstat (limited to 'anim/src/disasm.zig')
-rw-r--r--anim/src/disasm.zig17
1 files changed, 12 insertions, 5 deletions
diff --git a/anim/src/disasm.zig b/anim/src/disasm.zig
index efdb80e..6faaade 100644
--- a/anim/src/disasm.zig
+++ b/anim/src/disasm.zig
@@ -158,6 +158,11 @@ pub const Disasm = struct {
};
var last_line: ?u32 = null;
+ // A source of many lines (SQLite's) has wider numbers: what is
+ // right of them moves right by as much.
+ var widest: u32 = 0;
+ for (merged) |row| widest = @max(widest, row.line orelse 0);
+ const widen = rows.numberRoom(widest);
// The thread's runs: of the line the mark leaves and of the one it
// goes to, each a span of rows; published sliding from the one to
// the other with the advance (`threadRuns`).
@@ -182,7 +187,7 @@ pub const Disasm = struct {
const is_pc = row.addr == pc[if (going >= 0.5) 1 else 0];
const was = if (is_pc) null else ran[j];
if (was) |r| lit.trail(c.mark, y, r.k);
- const hangs = d.insn(lit, now, row, y, box.w, line, line != last_line, current_line, lead, if (is_pc) .current else if (was) |r| .{ .ran = r } else .ahead, base, covered > 0);
+ const hangs = d.insn(lit, now, row, y, box.w, widen, line, line != last_line, current_line, lead, if (is_pc) .current else if (was) |r| .{ .ran = r } else .ahead, base, covered > 0);
covered = @max(covered -| 1, hangs);
last_line = if (above_body) null else line;
if (jumped == row.addr and !is_pc) lanes[0] = y;
@@ -209,15 +214,17 @@ pub const Disasm = struct {
/// where the annotation carries the address they name. `covered`: a
/// call's arguments above hang in this row's annotation column. Returns
/// how many rows under it its own arguments hang in.
- fn insn(d: *const Disasm, u: ui.Ui, now: cursors.Now, row: Insn, y: f32, w: f32, line: ?u32, first_of_line: bool, current_line: u32, lead: usize, state: State, base: usize, covered: bool) usize {
+ fn insn(d: *const Disasm, at: ui.Ui, now: cursors.Now, row: Insn, y: f32, w: f32, widen: f32, line: ?u32, first_of_line: bool, current_line: u32, lead: usize, state: State, base: usize, covered: bool) usize {
const rec = d.cursor.rec;
const base_y = rows.baseline(y);
const code_ink = theme.color.region.code_;
- const room = w - m.side;
+ // Right of the line's column, all of it moved by `widen`.
+ const u = at.moved(widen, 0);
+ const room = w - m.side - widen;
if (row.outside) {
// The function ends: a rule, and the next one's name.
u.fill(.{ .x = theme.stroke.rule, .y = y, .w = w - 2 * theme.stroke.rule, .h = theme.stroke.rule }, theme.color.rule);
- _ = u.address(c.address, base_y, row.addr, .{ .ink = ui.mix(code_ink, theme.color.page, theme.metric.context.lead_alpha) });
+ _ = at.address(c.address, base_y, row.addr, .{ .ink = ui.mix(code_ink, theme.color.page, theme.metric.context.lead_alpha) });
u.text(.mono, size, c.mnemonic, base_y, row.mnemonic(), t.faint);
const name = if (rec.strings.get(row.addr)) |n| n[0 .. std.mem.lastIndexOfScalar(u8, n, '+') orelse n.len] else "";
const x = if (name.len > 0) annotationX(operandsWidth(row, row.operands()), room, @as(f32, @floatFromInt(name.len)) * adv) else room + gap;
@@ -225,7 +232,7 @@ pub const Disasm = struct {
u.text(.mono, size, x, base_y, name, t.faint);
return 0;
}
- _ = u.address(c.address, base_y, row.addr, .{ .ink = ui.rgb(code_ink), .lead = lead });
+ _ = at.address(c.address, base_y, row.addr, .{ .ink = ui.rgb(code_ink), .lead = lead });
if (first_of_line) if (line) |l| {
const num = u.print("{d}", .{l});
const now_line = l == current_line;