Compute the total visual line count, accounting for wrap. `prefix_w` is the display width of the line prefix (e.g. 2 for "> ").
(&self, inner_width: u16, prefix_w: usize)
| 220 | /// Compute the total visual line count, accounting for wrap. |
| 221 | /// `prefix_w` is the display width of the line prefix (e.g. 2 for "> "). |
| 222 | pub fn visual_line_count_with_prefix(&self, inner_width: u16, prefix_w: usize) -> usize { |
| 223 | if self.input.is_empty() { |
| 224 | return 1; |
| 225 | } |
| 226 | let avail = Self::avail_width(inner_width, prefix_w); |
| 227 | self.input |
| 228 | .split('\n') |
| 229 | .map(|line_text| { |
| 230 | let text_w = line_text.width(); |
| 231 | if text_w == 0 { |
| 232 | 1 |
| 233 | } else { |
| 234 | (text_w + avail - 1) / avail |
| 235 | } |
| 236 | }) |
| 237 | .sum() |
| 238 | } |
| 239 | |
| 240 | /// Convenience: compute visual line count using default prefix width of 2. |
| 241 | pub fn visual_line_count(&self, inner_width: u16) -> usize { |
no test coverage detected