diff options
Diffstat (limited to 'alacritty_terminal/src')
-rw-r--r-- | alacritty_terminal/src/grid/mod.rs | 2 | ||||
-rw-r--r-- | alacritty_terminal/src/grid/row.rs | 27 | ||||
-rw-r--r-- | alacritty_terminal/src/grid/storage.rs | 13 | ||||
-rw-r--r-- | alacritty_terminal/src/grid/tests.rs | 2 | ||||
-rw-r--r-- | alacritty_terminal/src/term/cell.rs | 1 |
5 files changed, 35 insertions, 10 deletions
diff --git a/alacritty_terminal/src/grid/mod.rs b/alacritty_terminal/src/grid/mod.rs index 792dd844..1925a6f4 100644 --- a/alacritty_terminal/src/grid/mod.rs +++ b/alacritty_terminal/src/grid/mod.rs @@ -565,7 +565,7 @@ impl<T> Grid<T> { /// This is used only for initializing after loading ref-tests pub fn initialize_all(&mut self, template: &T) where - T: Copy, + T: Copy + GridCell, { let history_size = self.raw.len().saturating_sub(*self.lines); self.raw.initialize(self.max_scroll_limit - history_size, Row::new(self.cols, template)); diff --git a/alacritty_terminal/src/grid/row.rs b/alacritty_terminal/src/grid/row.rs index b67f8cd4..f82e7eaa 100644 --- a/alacritty_terminal/src/grid/row.rs +++ b/alacritty_terminal/src/grid/row.rs @@ -45,8 +45,12 @@ impl<T: PartialEq> PartialEq for Row<T> { } impl<T: Copy> Row<T> { - pub fn new(columns: Column, template: &T) -> Row<T> { - Row { inner: vec![*template; *columns], occ: 0 } + pub fn new(columns: Column, template: &T) -> Row<T> + where + T: GridCell, + { + let occ = if template.is_empty() { 0 } else { columns.0 }; + Row { inner: vec![*template; columns.0], occ } } pub fn grow(&mut self, cols: Column, template: &T) { @@ -70,7 +74,7 @@ impl<T: Copy> Row<T> { let index = new_row.iter().rposition(|c| !c.is_empty()).map(|i| i + 1).unwrap_or(0); new_row.truncate(index); - self.occ = min(self.occ, *cols); + self.occ = min(self.occ, cols.0); if new_row.is_empty() { None @@ -80,11 +84,17 @@ impl<T: Copy> Row<T> { } /// Resets contents to the contents of `other` - pub fn reset(&mut self, other: &T) { - for item in &mut self.inner[..] { - *item = *other; + pub fn reset(&mut self, template: &T) + where + T: GridCell, + { + for item in &mut self.inner[..self.occ] { + *item = *template; + } + + if template.is_empty() { + self.occ = 0; } - self.occ = 0; } } @@ -116,13 +126,14 @@ impl<T> Row<T> { where T: GridCell, { + self.occ += vec.len(); self.inner.append(vec); - self.occ = self.inner.iter().rposition(|c| !c.is_empty()).map(|i| i + 1).unwrap_or(0); } #[inline] pub fn append_front(&mut self, mut vec: Vec<T>) { self.occ += vec.len(); + vec.append(&mut self.inner); self.inner = vec; } diff --git a/alacritty_terminal/src/grid/storage.rs b/alacritty_terminal/src/grid/storage.rs index 9b8b0b2a..e04d01cd 100644 --- a/alacritty_terminal/src/grid/storage.rs +++ b/alacritty_terminal/src/grid/storage.rs @@ -310,8 +310,21 @@ impl<T> IndexMut<Line> for Storage<T> { mod test { use crate::grid::row::Row; use crate::grid::storage::Storage; + use crate::grid::GridCell; use crate::index::{Column, Line}; + impl GridCell for char { + fn is_empty(&self) -> bool { + *self == ' ' || *self == '\t' + } + + fn is_wrap(&self) -> bool { + false + } + + fn set_wrap(&mut self, _wrap: bool) {} + } + /// Grow the buffer one line at the end of the buffer /// /// Before: diff --git a/alacritty_terminal/src/grid/tests.rs b/alacritty_terminal/src/grid/tests.rs index ce094b96..a352e747 100644 --- a/alacritty_terminal/src/grid/tests.rs +++ b/alacritty_terminal/src/grid/tests.rs @@ -21,7 +21,7 @@ use crate::term::cell::{Cell, Flags}; impl GridCell for usize { fn is_empty(&self) -> bool { - false + *self == 0 } fn is_wrap(&self) -> bool { diff --git a/alacritty_terminal/src/term/cell.rs b/alacritty_terminal/src/term/cell.rs index 4d2f4c1c..5e2762d2 100644 --- a/alacritty_terminal/src/term/cell.rs +++ b/alacritty_terminal/src/term/cell.rs @@ -63,6 +63,7 @@ impl GridCell for Cell { (self.c == ' ' || self.c == '\t') && self.extra[0] == ' ' && self.bg == Color::Named(NamedColor::Background) + && self.fg == Color::Named(NamedColor::Foreground) && !self .flags .intersects(Flags::INVERSE | Flags::UNDERLINE | Flags::STRIKEOUT | Flags::WRAPLINE) |