Support editor::SelectAll in Terminal
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user