Is your feature request related to a problem?
WORDS wrap only breaks at whitespace, so a single word wider than the content box is emitted as one over-wide line that bleeds past the box with no way to break inside it. In a 10-wide bordered box (8 cols of content), "Hellooooooooooooo World" lays out as one long line that spills onto the top-border row entirely outside the box—row 0 prints ┌────────┐oooooooo W while every interior row is blank.
Describe the solution you'd like
An opt-in hard-break mode that mirrors the CSS overflow-wrap property: when a word's measured width exceeds the content width, split at the overflowing cell and continue on the next line until the remainder fits. At width 8, "Hellooooooooooooo World" becomes Helloooo / oooooooo / o World. One extra wrap value or a breakWord flag (exact name TBD):
text("Hellooooooooooooo World", { wrap: 3 }); // WORDS + hard-break
text("Hellooooooooooooo World", { breakWord: true });
Wide runs must split on cell boundaries, not bytes, to stay correct with wcwidth. Default WORDS behavior must stay byte-for-byte identical.
Describe alternatives you've considered
Pre-segmenting overlong runs in JS before text(): unreliable, since it would re-implement wcwidth-aware measurement and need the laid-out content width before layout exists. The break has to happen where the width is known, in the measurement pass.
Additional context
Failing test case on nm/repro/hard-word-break (test · diff). Likely lives in src/clayterm.c:269, where render_text advances x += cw per glyph with no content-width clamp, with the mid-word split landing in Clay's word loop at clay/clay.h:2559-2564.
Is your feature request related to a problem?
WORDS wrap only breaks at whitespace, so a single word wider than the content box is emitted as one over-wide line that bleeds past the box with no way to break inside it. In a 10-wide bordered box (8 cols of content),
"Hellooooooooooooo World"lays out as one long line that spills onto the top-border row entirely outside the box—row 0 prints┌────────┐oooooooo Wwhile every interior row is blank.Describe the solution you'd like
An opt-in hard-break mode that mirrors the CSS
overflow-wrapproperty: when a word's measured width exceeds the content width, split at the overflowing cell and continue on the next line until the remainder fits. At width 8,"Hellooooooooooooo World"becomesHelloooo/oooooooo/o World. One extra wrap value or abreakWordflag (exact name TBD):Wide runs must split on cell boundaries, not bytes, to stay correct with
wcwidth. Default WORDS behavior must stay byte-for-byte identical.Describe alternatives you've considered
Pre-segmenting overlong runs in JS before
text(): unreliable, since it would re-implementwcwidth-aware measurement and need the laid-out content width before layout exists. The break has to happen where the width is known, in the measurement pass.Additional context
Failing test case on
nm/repro/hard-word-break(test · diff). Likely lives insrc/clayterm.c:269, whererender_textadvancesx += cwper glyph with no content-width clamp, with the mid-word split landing in Clay's word loop atclay/clay.h:2559-2564.