From fc2ef0991ef2205fd975a95298bc98823015b791 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Tue, 29 May 2018 21:45:28 -0700 Subject: [PATCH] Remove dead code --- src/event.rs | 2 +- src/grid/mod.rs | 1 - src/grid/storage.rs | 43 ------------------------------------------- src/selection.rs | 23 +++++------------------ 4 files changed, 6 insertions(+), 63 deletions(-) diff --git a/src/event.rs b/src/event.rs index 1cdf1302..4a0e8d1c 100644 --- a/src/event.rs +++ b/src/event.rs @@ -99,7 +99,7 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> { fn semantic_selection(&mut self, point: Point) { let point = self.terminal.visible_to_buffer(point); - *self.terminal.selection_mut() = Some(Selection::semantic(point, &*self.terminal)); + *self.terminal.selection_mut() = Some(Selection::semantic(point)); self.terminal.dirty = true; } diff --git a/src/grid/mod.rs b/src/grid/mod.rs index b03ae54f..97614d71 100644 --- a/src/grid/mod.rs +++ b/src/grid/mod.rs @@ -230,7 +230,6 @@ impl Grid { new_line_count: index::Line, template: &T, ) { - let previous_scroll_limit = self.scroll_limit; let lines_added = new_line_count - self.lines; // Need to "resize" before updating buffer diff --git a/src/grid/storage.rs b/src/grid/storage.rs index 0f0f611b..d517fa01 100644 --- a/src/grid/storage.rs +++ b/src/grid/storage.rs @@ -172,25 +172,11 @@ impl Storage { self.len } - #[inline] - pub fn raw_len(&self) -> usize { - self.inner.len() - } - /// Compute actual index in underlying storage given the requested index. fn compute_index(&self, requested: usize) -> usize { (requested + self.zero) % self.inner.len() } - #[inline] - pub fn line_offset(&self) -> usize { - self.inner.len() + self.zero + *self.visible_lines - } - - pub fn compute_line_index(&self, a: Line) -> usize { - (self.line_offset() - *a) % self.inner.len() - } - pub fn swap_lines(&mut self, a: Line, b: Line) { let offset = self.inner.len() + self.zero + *self.visible_lines; let a = (offset - *a) % self.inner.len(); @@ -234,13 +220,6 @@ impl Storage { } } - /// Iterator over *logical* entries in the storage - /// - /// This *does not* iterate over hidden entries. - pub fn iter_mut(&mut self) -> IterMut { - IterMut { storage: self, index: 0 } - } - /// Iterate over *all* entries in the underlying buffer /// /// This includes hidden entries. @@ -300,28 +279,6 @@ impl IndexMut for Storage { } } -pub struct IterMut<'a, T: 'a> { - storage: &'a mut Storage, - index: usize, -} - -impl<'a, T: 'a> Iterator for IterMut<'a, T> { - type Item = &'a mut Row; - - fn next(&mut self) -> Option { - if self.index == self.storage.len() { - None - } else { - let index = self.index; - self.index += 1; - - unsafe { - Some(&mut *(&mut self.storage[index] as *mut _)) - } - } - } -} - #[cfg(test)] use index::Column; diff --git a/src/selection.rs b/src/selection.rs index a54bd49d..dca16e26 100644 --- a/src/selection.rs +++ b/src/selection.rs @@ -47,11 +47,6 @@ pub enum Selection { Semantic { /// The region representing start and end of cursor movement region: Range>, - - /// When beginning a semantic selection, the grid is searched around the - /// initial point to find semantic escapes, and this initial expansion - /// marks those points. - initial_expansion: Range> }, Lines { /// The region representing start and end of cursor movement @@ -109,11 +104,9 @@ impl Selection { region.start.point.line = (region.start.point.line as isize + offset) as usize; region.end.point.line = (region.end.point.line as isize + offset) as usize; }, - Selection::Semantic { ref mut region, ref mut initial_expansion } => { + Selection::Semantic { ref mut region } => { region.start.line = (region.start.line as isize + offset) as usize; region.end.line = (region.end.line as isize + offset) as usize; - initial_expansion.start.line = (initial_expansion.start.line as isize + offset) as usize; - initial_expansion.end.line = (initial_expansion.end.line as isize + offset) as usize; }, Selection::Lines { ref mut region, ref mut initial_line } => { region.start.line = (region.start.line as isize + offset) as usize; @@ -123,16 +116,11 @@ impl Selection { } } - pub fn semantic(point: Point, grid: &G) -> Selection { - let (start, end) = (grid.semantic_search_left(point), grid.semantic_search_right(point)); + pub fn semantic(point: Point) -> Selection { Selection::Semantic { region: Range { start: point, end: point, - }, - initial_expansion: Range { - start: start, - end: end } } } @@ -153,7 +141,7 @@ impl Selection { Selection::Simple { ref mut region } => { region.end = Anchor::new(location, side); }, - Selection::Semantic { ref mut region, .. } | + Selection::Semantic { ref mut region } | Selection::Lines { ref mut region, .. } => { region.end = location; @@ -166,8 +154,8 @@ impl Selection { Selection::Simple { ref region } => { Selection::span_simple(grid, region) }, - Selection::Semantic { ref region, ref initial_expansion } => { - Selection::span_semantic(grid, region, initial_expansion) + Selection::Semantic { ref region } => { + Selection::span_semantic(grid, region) }, Selection::Lines { ref region, ref initial_line } => { Selection::span_lines(grid, region, *initial_line) @@ -177,7 +165,6 @@ impl Selection { fn span_semantic( grid: &G, region: &Range>, - initial_expansion: &Range> ) -> Option where G: SemanticSearch + Dimensions {