diff options
Diffstat (limited to 'src/term/cell.rs')
-rw-r--r-- | src/term/cell.rs | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/src/term/cell.rs b/src/term/cell.rs index 5d3b7036..88f9d7a1 100644 --- a/src/term/cell.rs +++ b/src/term/cell.rs @@ -14,7 +14,7 @@ use bitflags::bitflags; use crate::ansi::{NamedColor, Color}; -use crate::grid; +use crate::grid::{self, GridCell}; use crate::index::Column; // Maximum number of zerowidth characters which will be stored per cell. @@ -62,6 +62,32 @@ impl Default for Cell { } +impl GridCell for Cell { + #[inline] + fn is_empty(&self) -> bool { + (self.c == ' ' || self.c == '\t') + && self.extra[0] == ' ' + && self.bg == Color::Named(NamedColor::Background) + && !self + .flags + .intersects(Flags::INVERSE | Flags::UNDERLINE | Flags::STRIKEOUT | Flags::WRAPLINE) + } + + #[inline] + fn is_wrap(&self) -> bool { + self.flags.contains(Flags::WRAPLINE) + } + + #[inline] + fn set_wrap(&mut self, wrap: bool) { + if wrap { + self.flags.insert(Flags::WRAPLINE); + } else { + self.flags.remove(Flags::WRAPLINE); + } + } +} + /// Get the length of occupied cells in a line pub trait LineLength { /// Calculate the occupied line length @@ -114,14 +140,6 @@ impl Cell { } #[inline] - pub fn is_empty(&self) -> bool { - (self.c == ' ' || self.c == '\t') - && self.extra[0] == ' ' - && self.bg == Color::Named(NamedColor::Background) - && !self.flags.intersects(Flags::INVERSE | Flags::UNDERLINE | Flags::STRIKEOUT) - } - - #[inline] pub fn reset(&mut self, template: &Cell) { // memcpy template to self *self = *template; |