Implement select all

This commit is contained in:
Jeremy Soller 2023-12-22 15:08:24 -07:00
parent 40c871bcf3
commit 2a4d9f0d28
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
2 changed files with 17 additions and 2 deletions

View file

@ -456,7 +456,8 @@ impl Application for App {
Message::SelectAll(entity_opt) => {
let entity = entity_opt.unwrap_or_else(|| self.tab_model.active());
if let Some(terminal) = self.tab_model.data::<Mutex<Terminal>>(entity) {
log::warn!("TODO: SELECT ALL");
let mut terminal = terminal.lock().unwrap();
terminal.select_all();
}
}
Message::SystemThemeModeChange(_theme_mode) => {

View file

@ -4,7 +4,8 @@ use alacritty_terminal::{
event::{Event, EventListener, Notify, OnResize, WindowSize},
event_loop::{EventLoop, Msg, Notifier},
grid::Dimensions,
index::Point,
index::{Column, Line, Point, Side},
selection::{Selection, SelectionType},
sync::FairMutex,
term::{
cell::Flags,
@ -284,6 +285,19 @@ impl Terminal {
}
}
pub fn select_all(&mut self) {
{
let mut term = self.term.lock();
let grid = term.grid();
let start = Point::new(Line(-(grid.history_size() as i32)), Column(0));
let end = Point::new(Line(grid.screen_lines() as i32), Column(grid.columns()));
let mut selection = Selection::new(SelectionType::Lines, start, Side::Left);
selection.update(end, Side::Right);
term.selection = Some(selection);
}
self.update();
}
pub fn set_config(&mut self, config: &crate::Config, themes: &HashMap<String, Colors>) {
let mut update_cell_size = false;
let mut update = false;