diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-10-29 15:46:27 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-10-29 15:46:27 -0400 |
commit | 1f7cb68522ceb57187bcc9353bc2be405a927015 (patch) | |
tree | 58773e43f78df241f003a0c02ff3f1d5ed56db21 /src/cell.rs | |
parent | 267f7452949617375c8570caf4b03b434e3350e8 (diff) | |
download | vt100-rust-1f7cb68522ceb57187bcc9353bc2be405a927015.tar.gz vt100-rust-1f7cb68522ceb57187bcc9353bc2be405a927015.zip |
get some tests passing
Diffstat (limited to 'src/cell.rs')
-rw-r--r-- | src/cell.rs | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/src/cell.rs b/src/cell.rs index b1821c6..b5210e5 100644 --- a/src/cell.rs +++ b/src/cell.rs @@ -1,12 +1,7 @@ -#[derive(Clone, Debug)] +#[derive(Clone, Debug, Default)] pub struct Cell { contents: String, - fgcolor: crate::color::Color, - bgcolor: crate::color::Color, - bold: bool, - italic: bool, - inverse: bool, - underline: bool, + attrs: crate::attrs::Attrs, } impl Cell { @@ -14,45 +9,36 @@ impl Cell { Self::default() } + pub(crate) fn set(&mut self, c: String, a: crate::attrs::Attrs) { + self.contents = c; + self.attrs = a; + } + pub fn contents(&self) -> &str { &self.contents } pub fn fgcolor(&self) -> crate::color::Color { - self.fgcolor + self.attrs.fgcolor } pub fn bgcolor(&self) -> crate::color::Color { - self.bgcolor + self.attrs.bgcolor } pub fn bold(&self) -> bool { - self.bold + self.attrs.bold } pub fn italic(&self) -> bool { - self.italic + self.attrs.italic } pub fn inverse(&self) -> bool { - self.inverse + self.attrs.inverse } pub fn underline(&self) -> bool { - self.underline - } -} - -impl Default for Cell { - fn default() -> Self { - Self { - contents: String::new(), - fgcolor: crate::color::Color::Default, - bgcolor: crate::color::Color::Default, - bold: false, - italic: false, - inverse: false, - underline: false, - } + self.attrs.underline } } |