1
0
зеркало из https://github.com/glebtv/tui-textarea.git synced 2026-09-04 06:45:50 +03:00

implement TextArea::select_all

but it is not assigned to default key shortcuts because C-a is already
in use.
Этот коммит содержится в:
rhysd
2023-11-15 00:11:18 +09:00
родитель 9d03463237
Коммит 523a888f26
3 изменённых файлов: 33 добавлений и 0 удалений

Просмотреть файл

@@ -1312,6 +1312,26 @@ impl<'a> TextArea<'a> {
self.selection_start = None;
}
/// Select the entire text. Cursor moves to the end of the text buffer. When text selection is already ongoing,
/// it is canceled.
/// ```
/// use tui_textarea::{TextArea, CursorMove};
///
/// let mut textarea = TextArea::from(["aaa", "bbb", "ccc"]);
///
/// textarea.select_all();
///
/// // Cut the entire text;
/// textarea.cut();
///
/// assert_eq!(textarea.lines(), [""]); // Buffer is now empty
/// assert_eq!(textarea.yank_text(), "aaa\nbbb\nccc");
/// ```
pub fn select_all(&mut self) {
self.move_cursor(CursorMove::Jump(u16::MAX, u16::MAX));
self.selection_start = Some((0, 0));
}
/// Return if text selection is ongoing or not.
/// ```
/// use tui_textarea::{TextArea};