pub fn cursor_line_for_text_position(&self, text_pos: usize) -> Line {
        self.layout
            .as_ref()
            .map(|layout| {
                let pos = layout.hit_test_text_position(text_pos);
                let line_metrics = layout.line_metric(pos.line).unwrap();
                let p1 = (pos.point.x, line_metrics.y_offset);
                let p2 = (pos.point.x, (line_metrics.y_offset + line_metrics.height));
                Line::new(p1, p2)
            })
            .unwrap_or_else(|| Line::new(Point::ZERO, Point::ZERO))
    }
/// Given the utf-8 position of a character boundary in the underlying text,
/// return a `Line` suitable for drawing a vertical cursor at that boundary.
Given the utf-8 position of a character boundary in the underlying text,
return a `Line` suitable for drawing a vertical cursor at that boundary.
Given the utf - 8 position of a character boundary in the underlying text return a ` Line ` suitable for drawing a vertical cursor at that boundary .
pub fn cursor_line_for_text_position(&self, text_pos: usize) -> Line {
        self.layout
            .as_ref()
            .map(|layout| {
                let pos = layout.hit_test_text_position(text_pos);
                let line_metrics = layout.line_metric(pos.line).unwrap();
                let p1 = (pos.point.x, line_metrics.y_offset);
                let p2 = (pos.point.x, (line_metrics.y_offset + line_metrics.height));
                Line::new(p1, p2)
            })
            .unwrap_or_else(|| Line::new(Point::ZERO, Point::ZERO))
    }
pub fn cursor_line_for_text_position ( & self , text_pos : usize ) -> Line { self . layout . as_ref ( ) . map ( | layout | { let pos = layout . hit_test_text_position ( text_pos ) ; let line_metrics = layout . line_metric ( pos . line ) . unwrap ( ) ; let p1 = ( pos . point . x , line_metrics . y_offset ) ; let p2 = ( pos . point . x , ( line_metrics . y_offset + line_metrics . height ) ) ; Line :: new ( p1 , p2 ) } ) . unwrap_or_else ( | | Line :: new ( Point :: ZERO , Point :: ZERO ) ) }
Given the utf-8 position of a character boundary in the underlying text,
return a `Line` suitable for drawing a vertical cursor at that boundary.
Given the utf - 8 position of a character boundary in the underlying text return a ` Line ` suitable for drawing a vertical cursor at that boundary .
&self
text_pos
usize
&self
text_pos
usize