зеркало из
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.
Этот коммит содержится в:
@@ -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};
|
||||
|
||||
Ссылка в новой задаче
Block a user