Skip to main content

wrap_with_cursor

Function wrap_with_cursor 

Source
pub fn wrap_with_cursor(
    text: &str,
    max_cols: usize,
    cursor_byte: usize,
) -> (Vec<String>, usize, usize)
Expand description

Wrap text to max_cols columns AND locate the cursor’s 2D position within the wrapped layout. Honours explicit \n as a hard line break (Shift+Enter in the input buffer). Returns (lines, cursor_row, cursor_col) where cursor_row is 0-based within lines and cursor_col is the display column within that row.

cursor_byte is a byte offset into text; text.len() (end-of-buffer) is the expected maximum.