Expand description
Soft-wrap helpers shared between the renderer, viewport scroll, and the buffer’s vertical motion code.
Enums§
- Wrap
- Soft-wrap mode controlling how doc rows wider than the text area
turn into multiple visual rows. Default is
Wrap::None— every doc row is exactly one screen row andtop_colclips the left side, mirroring vim’sset nowrapdefault for sqeel today.
Functions§
- char_
col_ for_ visual_ offset - Inverse of the per-char accounting
wrap_segmentsuses to find where a segment breaks: map a visual x offset (visual_offset, cells counted from the segment’s OWN left edge — i.e. 0 atseg.0, matching how the renderer paints each wrapped row starting at its text area’s left column regardless ofseg.0) to the char index withinseg = [start, end)it lands on. - segment_
for_ col - Returns the index into
segmentswhose[start, end)coverscol. The past-end cursor (col == last segment's end) maps to the last segment, matching vim’s “EOL on the visual row that holds the line’s last char” behaviour. - visual_
offset_ for_ char_ col - Forward companion to
char_col_for_visual_offset: map a char column (within a segment starting atseg_start) to its visual x offset, in cells counted from the segment’s OWN left edge — the exact inverse relationship, using the same per-char width formula.char_colshould be>= seg_start(typically chosen viasegment_for_colfirst); achar_colbeforeseg_startis treated asseg_start(offset 0). - wrap_
segments - Split
lineinto char-index segments[start, end)such that each segment’s display width fits withinwidthcells.Wrap::Wordrewinds 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 thanwidth.Wrap::Noneis not expected here — callers branch before calling — but is handled for completeness as a single segment covering the full line.