diff options
Diffstat (limited to 'src/grid/mod.rs')
-rw-r--r-- | src/grid/mod.rs | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/src/grid/mod.rs b/src/grid/mod.rs index b6cff604..f3c8ea79 100644 --- a/src/grid/mod.rs +++ b/src/grid/mod.rs @@ -52,23 +52,13 @@ impl<T> Deref for Indexed<T> { impl<T: PartialEq> ::std::cmp::PartialEq for Grid<T> { fn eq(&self, other: &Self) -> bool { - // Compare raw grid content - // TODO: This is pretty inefficient but only used in tests - let mut raw_match = true; - for i in 0..(self.lines.0 + self.history_size) { - for j in 0..self.cols.0 { - if self[i][Column(j)] != other[i][Column(j)] { - raw_match = false; - break; - } - } - } - // Compare struct fields and check result of grid comparison - self.cols.eq(&other.cols) && + self.raw.eq(&other.raw) && + self.cols.eq(&other.cols) && self.lines.eq(&other.lines) && - self.history_size.eq(&other.history_size) && - raw_match + self.display_offset.eq(&other.display_offset) && + self.scroll_limit.eq(&other.scroll_limit) && + self.selection.eq(&other.selection) } } @@ -102,10 +92,6 @@ pub struct Grid<T> { /// Selected region #[serde(skip)] pub selection: Option<Selection>, - - /// Maximum number of lines in the scrollback history - #[serde(default)] - history_size: usize, } pub struct GridIterator<'a, T: 'a> { @@ -150,7 +136,6 @@ impl<T: Copy + Clone> Grid<T> { display_offset: 0, scroll_limit: 0, selection: None, - history_size: scrollback, } } @@ -426,6 +411,12 @@ impl<T> Grid<T> { self.scroll_limit = 0; } + /// Total number of lines in the buffer, this includes scrollback + visible lines + #[inline] + pub fn len(&self) -> usize { + self.raw.len() + } + pub fn iter_from(&self, point: Point<usize>) -> GridIterator<T> { GridIterator { grid: self, |