summaryrefslogtreecommitdiff
path: root/anim/src/ui.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-12 04:45:57 -0300
committerGabriel Schneider <[email protected]>2026-11-12 07:03:05 -0300
commit4907e35bc45d12102d0e09380994814fc2e0a369 (patch)
tree7cfd90224653d73b63fbadaf2881fa0e6ba92860 /anim/src/ui.zig
parentebdebe04a76f0302aeb24c1ac08fa9217b1a8257 (diff)
downloadcomputeranim-4907e35bc45d12102d0e09380994814fc2e0a369.tar.gz
computeranim-4907e35bc45d12102d0e09380994814fc2e0a369.zip
canim: the introduction, from the review
The introduction records the plain build (clang -O0, no instrumentation), so reverse's frame is the compiler's own push, mov and sub. The stack chapter says its convention once and keeps four free words over rsp so a push moves the pin and nothing else; reverse's rows stand under main's and are stepped, each touching its word, the call before the push, the aim drawn head first to the row it returns to. The close-up frames the bytes and the stack together with their 128 bytes marked. Nothing is named before it is shown; offsets are written in hex as the operands are; the dump folds into its tag; the map is announced before it is shown. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNCKgYCGiANnEwcEQxa
Diffstat (limited to 'anim/src/ui.zig')
-rw-r--r--anim/src/ui.zig19
1 files changed, 14 insertions, 5 deletions
diff --git a/anim/src/ui.zig b/anim/src/ui.zig
index 589bfb6..eeac127 100644
--- a/anim/src/ui.zig
+++ b/anim/src/ui.zig
@@ -555,13 +555,14 @@ pub const Ui = struct {
u.fill(.{ .x = cx - p.stub / 2, .y = y + p.under_head[0] - 1, .w = p.stub, .h = rise - p.under_head[0] + 1 }, ink);
sk.draw.polygon(u.f, &.{ .{ cx, y + 1 }, .{ cx - p.under_head[1] / 2, y + 1 + p.under_head[0] }, .{ cx + p.under_head[1] / 2, y + 1 + p.under_head[0] } }, u.at.pen(.{ .fill = rgb(ink) }));
if (names.len == 0) return;
- u.pinNames(cx, y, names, inks, size);
+ u.pinNames(cx, y, names, inks, size, 0);
}
/// The names of a `pin` `under`: the first left of the stub, the
- /// second right of it ("" for a side kept free), the rest a count;
- /// each bold in `inks` (a variable's: where it lives) or primary.
- pub fn pinNames(u: Ui, cx: f32, y: f32, names: []const []const u8, inks: []const u24, size: f32) void {
+ /// second right of it ("" for a side kept free), the rest a count, or
+ /// by name where they fit before `room` (an x; 0: none); each bold in
+ /// `inks` (a variable's: where it lives) or primary.
+ pub fn pinNames(u: Ui, cx: f32, y: f32, names: []const []const u8, inks: []const u24, size: f32, room: f32) void {
const p = theme.metric.pin;
const by = y + 8 + size * 0.86;
const ink = struct {
@@ -573,7 +574,15 @@ pub const Ui = struct {
// One name a side: a node's neighbour has its own. The rest are a count.
if (names.len > 1) {
u.text(.mono_bold, size, cx + p.under_names, by, names[1], ink(inks, 1));
- if (names.len > 2) u.text(.mono_bold, size, cx + p.under_names + u.width(.mono, size, names[1]) + advance(size) / 2, by, u.print("+{d}", .{names.len - 2}), theme.color.text.primary);
+ var x = cx + p.under_names + u.width(.mono, size, names[1]) + advance(size) / 2;
+ var end = x;
+ for (names[2..]) |n| end += u.width(.mono, size, n) + advance(size) / 2;
+ if (names.len > 2 and end - advance(size) / 2 <= room) {
+ for (names[2..], 2..) |n, i| {
+ u.text(.mono_bold, size, x, by, n, ink(inks, i));
+ x += u.width(.mono, size, n) + advance(size) / 2;
+ }
+ } else if (names.len > 2) u.text(.mono_bold, size, x, by, u.print("+{d}", .{names.len - 2}), theme.color.text.primary);
}
}