diff --git a/src/textarea.rs b/src/textarea.rs index 0efd170..92d8f8c 100644 --- a/src/textarea.rs +++ b/src/textarea.rs @@ -2003,6 +2003,26 @@ impl<'a> TextArea<'a> { self.cursor } + /// Get the current selection start position. 0-base character-wise (row, col) selection start position. + /// ``` + /// use tui_textarea::TextArea; + /// + /// let mut textarea = TextArea::default(); + /// assert_eq!(textarea.selection_start(), None); + + /// textarea.insert_char('a'); + /// textarea.insert_newline(); + /// textarea.insert_char('b'); + /// + /// textarea.start_selection(); + /// assert_eq!(textarea.selection_start(), Some((0, 0))); + /// textarea.move_cursor(CursorMove::Forward); + /// assert_eq!(textarea.selection_start(), Some((0, 0))); + /// ``` + pub fn selection_start(&self) -> Option<(usize, usize)> { + self.selection_start + } + /// Set text alignment. When [`Alignment::Center`] or [`Alignment::Right`] is set, line number is automatically /// disabled because those alignments don't work well with line numbers. /// ```