Skip to main content

wrap_spans

Function wrap_spans 

Source
pub fn wrap_spans(spans: &[Span<'_>], width: u16) -> Vec<Line<'static>>
Expand description

Break spans into lines no wider than width, keeping each word under the style it arrived with.

Breaks on whitespace, and breaks inside a word only when the word cannot fit on a line of its own. A word longer than the whole width is the case that has no good answer; cutting it is the least bad one, because the alternative is a line wider than the region and a buffer that swallows the overflow silently.

The one wrap in this crate. wrap is this with a single style over the whole string, rather than a second implementation that would be free to disagree with it about how many rows a paragraph takes – and a disagreement there is a node drawing over the one under it.