Expand description
W3.4: pointer -> caret hit-test + word/line expansion.
No-dep helpers - these run without needing a shaped layout (the caller passes the text and an approximate average advance) so they’re usable from unit tests and from the input crate even when no shaper is wired (e.g. headless tests).
The real shaping-aware hit-test path is intended to consult the
per-entity ShapedRunIndex cache (W3.6) - once that exists, the
input crate can ask the shaper for xy_to_byte(x, y) and feed the
result through select_word_at_byte / select_line_at_byte
unchanged.
Functions§
- hit_
test_ text - Hit-test against a single-line run with a uniform per-char advance. Returns the byte offset whose glyph the pointer landed nearest.
- next_
word_ boundary - Byte offset of the end of the Unicode-word segment at/after
from. Seeprev_word_boundary. - prev_
word_ boundary - Byte offset of the start of the Unicode-word segment strictly before
from. Used for directional word motion (ctrl+<-, ctrl+Backspace) - shares thesplit_word_bound_indiceswalkselect_word_at_byteuses to expand a point into a range, but returns the boundary itself rather than a(start, end)pair. - select_
line_ at_ byte - Expand a byte offset into a line range.
\nis excluded from the end of the range so a triple-click select-then-replace doesn’t eat the newline. - select_
word_ at_ byte - Expand a byte offset into a word range using Unicode word boundaries.
Returns
(start, end)in bytes;start == end == bytewhen the click landed on whitespace.