aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/event.rs
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2020-05-30 20:45:44 +0000
committerGitHub <noreply@github.com>2020-05-30 20:45:44 +0000
commit1dacc99183373bffa3ba287aa3241f3b1da67016 (patch)
treed5dbefde927b02bff10e29d8596a0bfab65d88f1 /alacritty/src/event.rs
parentf7fb67f870943f3f760826b748c8463b8e434983 (diff)
downloadr-alacritty-1dacc99183373bffa3ba287aa3241f3b1da67016.tar.gz
r-alacritty-1dacc99183373bffa3ba287aa3241f3b1da67016.tar.bz2
r-alacritty-1dacc99183373bffa3ba287aa3241f3b1da67016.zip
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`.
Diffstat (limited to 'alacritty/src/event.rs')
-rw-r--r--alacritty/src/event.rs14
1 files changed, 7 insertions, 7 deletions
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<T> 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<T> 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<T> 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<T> 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<N: Notify + OnResize> Processor<N> {
// 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");