зеркало из
https://github.com/glebtv/tui-textarea.git
synced 2026-09-03 14:26:17 +03:00
expose selection_start
Этот коммит содержится в:
@@ -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.
|
||||
/// ```
|
||||
|
||||
Ссылка в новой задаче
Block a user