diff options
Diffstat (limited to 'anim/src/rows.zig')
| -rw-r--r-- | anim/src/rows.zig | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/anim/src/rows.zig b/anim/src/rows.zig index f82bb81..03c5898 100644 --- a/anim/src/rows.zig +++ b/anim/src/rows.zig @@ -122,7 +122,7 @@ pub fn chain(u: ui.Ui, x: f32, y: f32, moment: Recording.Moment, value: u64, roo const shown = ui.Value.of(link.value, pointer); const w = shown.width(); // The hops after a struck first one are followed again, one at a time. - const followed: f32 = if (marks.extend) |e| std.math.clamp((e - @as(f32, @floatFromInt(i -| 1)) * theme.time.unroll) / (6.0 / 60.0), 0, 1) else 1; + const followed: f32 = if (marks.extend) |e| std.math.clamp((e - @as(f32, @floatFromInt(i -| 1)) * theme.time.extend) / (6.0 / 60.0), 0, 1) else 1; const v = if (i > 0) u.faded(followed * marks.hops) else u; if (i > 0) { const named: f32 = if (link.region == .code and link.text.len > 0 and !link.string) 10 + @as(f32, @floatFromInt(link.text.len)) * adv else 0; @@ -148,6 +148,16 @@ pub fn chain(u: ui.Ui, x: f32, y: f32, moment: Recording.Moment, value: u64, roo if (marks.read == i) v.read(marked, marks.read_shows); if (pointer) { _ = v.address(at, base, link.value, .{ .ink = face_ink.ink, .face = face_ink.face, .lead = if (i == 0) marks.lead else 0, .rwx = link.region == .rwx }); + } else if (i == 0 and at + w > room) { + // A word too long for its row's room (a stack word beside its role): cut, with `…`. + const all = u.print("{s}{s}", .{ shown.prefix, shown.digits() }); + const fits: usize = @intFromFloat(std.math.clamp((room - at) / adv, 2, @as(f32, @floatFromInt(all.len)))); + v.text(face_ink.face, size, at, base, u.print("{s}\u{2026}", .{all[0 .. fits - 1]}), face_ink.ink); + at += @as(f32, @floatFromInt(fits)) * adv; + hops.x[0] = at - @as(f32, @floatFromInt(fits)) * adv; + hops.w[0] = @as(f32, @floatFromInt(fits)) * adv; + hops.n = 1; + break; } else _ = v.value(at, base, link.value, false, face_ink); if (hops.n < hops.x.len) { hops.x[hops.n] = at; @@ -198,6 +208,27 @@ pub fn reg(u: ui.Ui, y: f32, w: f32, name: []const u8, moment: Recording.Moment, return chain(u, m.chain_x, y, moment, value, w - m.side, marks); } +/// `registers` `quiet`: a register the scene never changes, in its cell +/// at `x`: its name faint, its value 48 in, in its ink; a pointer's chain +/// cut to `more` at once (a code address alone: its name is on the map), +/// framed as read while a step reads it (`read_shows`). +pub fn quiet(u: ui.Ui, x: f32, y: f32, name: []const u8, moment: Recording.Moment, value: u64, read_shows: f32) Hops { + u.text(.mono, size, x, baseline(y), name, t.faint); + const vx = x + theme.metric.registers.quiet_value; + const region = regionOf(moment, value); + const pointer = region != .none; + const shown = ui.Value.of(value, pointer); + if (read_shows > 0) u.read(.{ .x = vx, .y = y, .w = shown.width(), .h = row_h }, read_shows); + var hops: Hops = .{ .n = 1, .end = vx + shown.width() }; + hops.x[0] = vx; + hops.w[0] = shown.width(); + if (pointer) { + _ = u.address(vx, baseline(y), value, .{ .ink = ui.rgb(ink(region)), .rwx = region == .rwx }); + if (region != .code) hops.end = u.arrow(hops.end, y + row_h / 2, .more) + 24; + } else _ = u.value(vx, baseline(y), value, false, .{ .ink = ui.rgb(t.primary) }); + return hops; +} + /// The flags, in rip's row: their names, the value. pub const Flag = struct { name: []const u8, bit: u6 }; pub const flags = [_]Flag{ .{ .name = "CF", .bit = 0 }, .{ .name = "PF", .bit = 2 }, .{ .name = "AF", .bit = 4 }, .{ .name = "ZF", .bit = 6 }, .{ .name = "SF", .bit = 7 }, .{ .name = "IF", .bit = 9 }, .{ .name = "DF", .bit = 10 }, .{ .name = "OF", .bit = 11 } }; |
