summaryrefslogtreecommitdiff
path: root/examples/live/src/main.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-17 09:34:02 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commitae807468f15e81ea3b62fee4741ee6b246e6df8b (patch)
treedf454d45eb9fd0ee38a154b84f5c3c481b2786e9 /examples/live/src/main.zig
parentccdb7e478248fcf8489eb8a6f9b58178107a26f5 (diff)
downloadsketchbook-ae807468f15e81ea3b62fee4741ee6b246e6df8b.tar.gz
sketchbook-ae807468f15e81ea3b62fee4741ee6b246e6df8b.zip
examples/live: the name a line defines a step larger, by its syntax node
`paragraph` gives a span the scale 1.25 * 1.2 (`step`, 19.5 px against 16.25) where the grammar's class is the one queries/highlights.scm gives a definition's name node, `(definition name: (name) @keyword)`, and that node alone: chosen from the tree, not from the text's shape. The names are 12 pixels a character to the rest's 10, and a line with one is 26 high to 22. Everything of the last change lands on the mixed sizes, as everything is placed by sk.text.places: ranges, the carets, the problem's mark, the band, and the press that finds a number to drag. The scripts follow the layout: 220 on line 1 is now at x 182 to 212 (after the larger `out`), so the drags in test/live.script and test/story.script press at 187 instead of 181, every move 6 pixels on; the values they expect are the same. zig build test: 92 of 92 steps. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'examples/live/src/main.zig')
-rw-r--r--examples/live/src/main.zig7
1 files changed, 6 insertions, 1 deletions
diff --git a/examples/live/src/main.zig b/examples/live/src/main.zig
index 14058de..6e0f7e3 100644
--- a/examples/live/src/main.zig
+++ b/examples/live/src/main.zig
@@ -371,6 +371,8 @@ fn sound(s: *const State, ss: *Session, f: *sk.Frame) void {
}
const scale = 1.25;
+/// The name a line defines is this much larger than the rest.
+const step = 1.2;
const margin = 16;
const ink = 0xe8e8e8;
const red = 0xff5a50;
@@ -394,7 +396,10 @@ fn paragraph(a: std.mem.Allocator, ed: *const Editor, text: []const u8) sk.text.
for (classes, 0..) |class, i| {
if (i > 0 and classes[i - 1] == class) continue;
const c = pe.syntax.synInk(theme, class) orelse base;
- spans[n] = .{ .start = @intCast(i), .color = .{ .r = c[0], .g = c[1], .b = c[2] } };
+ // the name a line defines, a step larger: the class the grammar's
+ // highlights give a definition's name node, and it alone
+ // (queries/highlights.scm)
+ spans[n] = .{ .start = @intCast(i), .color = .{ .r = c[0], .g = c[1], .b = c[2] }, .scale = if (class == .keyword) scale * step else null };
n += 1;
}
p.spans = spans;