Skip to main content

rendered_row_count

Function rendered_row_count 

Source
pub fn rendered_row_count(input: &str, content_width: usize) -> usize
Expand description

How many rendered rows input occupies at content_width display cells.

content_width is the box’s inner width — the same value calculate_cursor_position takes — and the 2-cell "> " / " " prefix is subtracted here, so a caller passes one width and cannot get the two out of step.

Built on layout_rows for the same reason the cursor is: the layout picks whitespace breaks, so it starts a row earlier than counting cells to the hard edge would. A separate row count that hard-broke instead reported one row too few for any input whose last word wrapped — the box clipped its final line and the caret was drawn on the row the box did not have.