From 1dacc99183373bffa3ba287aa3241f3b1da67016 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sat, 30 May 2020 20:45:44 +0000 Subject: Refactor Term/Grid separation This commit aims to clear up the separation between Term and Grid to make way for implementing search. The `cursor` and `cursor_save` have been moved to the grid, since they're always bound to their specific grid and this makes updating easier. Since the selection is independent of the active grid, it has been moved to the `Term`. --- alacritty/src/event.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'alacritty/src/event.rs') diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index e11903ef..0de130b9 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -95,7 +95,7 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext for ActionCon // Update selection. if self.terminal.mode().contains(TermMode::VI) - && self.terminal.selection().as_ref().map(|s| s.is_empty()) != Some(true) + && self.terminal.selection.as_ref().map(|s| s.is_empty()) != Some(true) { self.update_selection(self.terminal.vi_mode_cursor.point, Side::Right); } else if ElementState::Pressed == self.mouse().left_button_state { @@ -116,11 +116,11 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext for ActionCon } fn selection_is_empty(&self) -> bool { - self.terminal.selection().as_ref().map(Selection::is_empty).unwrap_or(true) + self.terminal.selection.as_ref().map(Selection::is_empty).unwrap_or(true) } fn clear_selection(&mut self) { - *self.terminal.selection_mut() = None; + self.terminal.selection = None; self.terminal.dirty = true; } @@ -129,7 +129,7 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext for ActionCon // Update selection if one exists. let vi_mode = self.terminal.mode().contains(TermMode::VI); - if let Some(selection) = self.terminal.selection_mut() { + if let Some(selection) = &mut self.terminal.selection { selection.update(point, side); if vi_mode { @@ -142,12 +142,12 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext for ActionCon fn start_selection(&mut self, ty: SelectionType, point: Point, side: Side) { let point = self.terminal.visible_to_buffer(point); - *self.terminal.selection_mut() = Some(Selection::new(ty, point, side)); + self.terminal.selection = Some(Selection::new(ty, point, side)); self.terminal.dirty = true; } fn toggle_selection(&mut self, ty: SelectionType, point: Point, side: Side) { - match self.terminal.selection_mut() { + match &mut self.terminal.selection { Some(selection) if selection.ty == ty && !selection.is_empty() => { self.clear_selection(); }, @@ -745,7 +745,7 @@ impl Processor { // Dump grid state. let mut grid = terminal.grid().clone(); - grid.initialize_all(&Cell::default()); + grid.initialize_all(Cell::default()); grid.truncate(); let serialized_grid = json::to_string(&grid).expect("serialize grid"); -- cgit