Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Support editor::SelectAll in Terminal
Kirill Bulatovde69f08c1076
diff --git a/crates/terminal/src/terminal.rs b/crates/terminal/src/terminal.rsindex f6cfe5ae309..3bae06a86dc 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.rsindex 970e0115df2..b48597d9013 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>) {+ self.terminal.update(cx, |term, _| term.select_all());+ cx.notify();+ }+fn clear(&mut self, _: &Clear, cx: &mut ViewContext<Self>) {self.terminal.update(cx, |term, _| term.clear());cx.notify();