Skip to main content

wrap_segments

Function wrap_segments 

Source
pub fn wrap_segments(line: &str, width: u16, mode: Wrap) -> Vec<(usize, usize)>
Expand description

Split line into char-index segments [start, end) such that each segment’s display width fits within width cells. Wrap::Word rewinds to the last whitespace inside the candidate segment when a break would otherwise split a word; falls through to a char break for runs longer than width. Wrap::None is not expected here — callers branch before calling — but is handled for completeness as a single segment covering the full line.