Get the visual character at a given visual position, or None if past end.
(raw: &str, visual_pos: usize)
| 2314 | |
| 2315 | /// Get the visual character at a given visual position, or None if past end. |
| 2316 | pub fn visual_char_at(raw: &str, visual_pos: usize) -> Option<char> { |
| 2317 | let raw_pos = cursor_to_raw(raw, visual_pos); |
| 2318 | let chars: Vec<char> = raw.chars().collect(); |
| 2319 | if raw_pos >= chars.len() { |
| 2320 | return None; |
| 2321 | } |
| 2322 | // If the char at raw_pos is `\`, the visible char is the next one |
| 2323 | if chars[raw_pos] == '\\' && raw_pos + 1 < chars.len() { |
| 2324 | Some(chars[raw_pos + 1]) |
| 2325 | } else { |
| 2326 | Some(chars[raw_pos]) |
| 2327 | } |
| 2328 | } |
| 2329 | |
| 2330 | /// Strip all styling markup from a raw string, returning only visible text. |
| 2331 | pub fn strip_styling(raw: &str) -> String { |
nothing calls this directly
no test coverage detected