diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rs index f6cfe5ae30..3bae06a86d 100644 --- a/crates/terminal/src/terminal.rs +++ b/crates/terminal/src/terminal.rs @@ -987,6 +987,14 @@ impl Terminal { } } + pub fn select_all(&mut self) { + let term = self.term.lock(); + let start = Point::new(term.topmost_line(), Column(0)); + let end = Point::new(term.bottommost_line(), term.last_column()); + drop(term); + self.set_selection(Some((make_selection(&(start..=end)), end))); + } + fn set_selection(&mut self, selection: Option<(Selection, Point)>) { self.events .push_back(InternalEvent::SetSelection(selection)); diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index 970e0115df..b48597d901 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -80,6 +80,7 @@ pub fn init(cx: &mut AppContext) { cx.add_action(TerminalView::paste); cx.add_action(TerminalView::clear); cx.add_action(TerminalView::show_character_palette); + cx.add_action(TerminalView::select_all) } ///A terminal view, maintains the PTY's file handles and communicates with the terminal @@ -312,6 +313,11 @@ impl TerminalView { } } + fn select_all(&mut self, _: &editor::SelectAll, cx: &mut ViewContext) { + self.terminal.update(cx, |term, _| term.select_all()); + cx.notify(); + } + fn clear(&mut self, _: &Clear, cx: &mut ViewContext) { self.terminal.update(cx, |term, _| term.clear()); cx.notify();