diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 09:29:57 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | 7ad16df2813c0c3012bae6262014b07b7bc7277d (patch) | |
| tree | a144817721d20308f8bd0b0b8531c5c9bfa6b383 /src/sketch/root.zig | |
| parent | ecdb435ce789ed81d0edfaf25268848ae1e57442 (diff) | |
| download | sketchbook-7ad16df2813c0c3012bae6262014b07b7bc7277d.tar.gz sketchbook-7ad16df2813c0c3012bae6262014b07b7bc7277d.zip | |
text: sk.text.places, every byte's place in one layout
An editor draws a range under its bytes, a caret on its glyph, a mark
under a byte, and finds the byte under the pointer; with mixed sizes on
a line a column is no longer a measure. `layout`'s `caret` gives one
byte's place a layout, so a range, a caret and a hit test were a layout
a byte. `sk.text.places(bytes, paragraph, out)` is the same layout with
every byte's place in `out` (where a caret before that byte sits, a
`Caret`: x, the line's top and height; a `\n` and the spaces a line
wraps at are at its end, and one more for the end of the text). The
byte at a point is then a loop over places: the last whose line holds
its y and whose x is at or left of it. `lay` takes the slice to fill
(empty: none), so `layout`, `places` and `f.paragraph` stay one
function. Pure, as `layout`: in `update` too. The README's editor recipe
and docs/text.md say so.
Test: a paragraph's places are where its caret sits, byte by byte
(wrapped at a space, a `\n`, a span twice the size, a two-byte
codepoint, a last empty line). zig build test-text: 52 of 52 steps.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/sketch/root.zig')
| -rw-r--r-- | src/sketch/root.zig | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/sketch/root.zig b/src/sketch/root.zig index 8a24417..490b2f9 100644 --- a/src/sketch/root.zig +++ b/src/sketch/root.zig @@ -177,7 +177,7 @@ pub const Frame = struct { /// to wrap at, alignment, spans, the glyphs revealed, a caret), drawn; /// its `Layout` returned, as `sk.text.layout` gives it, from `x`, `y`. pub fn paragraph(f: *Frame, x: f32, y: f32, bytes: []const u8, p: text_module.Paragraph) text_module.Layout { - return text_module.lay(f.keep(u8, bytes), p, x, y, f); + return text_module.lay(f.keep(u8, bytes), p, x, y, f, &.{}); } /// `textIn` laid out and rasterized at `raster` and drawn at `scale`, /// its position not snapped to a pixel: for text under a moving |
