diff options
author | Jesse Luehrs <doy@tozt.net> | 2019-11-01 14:07:18 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2019-11-01 14:07:18 -0400 |
commit | aadfe4f9155818054c52140bc5f919cea4fde9cb (patch) | |
tree | b5a5fd671284c085705a4a19eecd1e6bfb99301e | |
parent | 1b0bca8204b25f46c68202f9b8e90801f41b35c9 (diff) | |
download | vt100-rust-aadfe4f9155818054c52140bc5f919cea4fde9cb.tar.gz vt100-rust-aadfe4f9155818054c52140bc5f919cea4fde9cb.zip |
implement a few more sgr modes
-rw-r--r-- | src/screen.rs | 14 | ||||
-rw-r--r-- | tests/attr.rs | 27 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/screen.rs b/src/screen.rs index 6216625..9381e6b 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -450,6 +450,9 @@ impl State { _ => {} } } + 39 => { + self.attrs.fgcolor = crate::color::Color::Default; + } n if n >= 40 && n <= 47 => { self.attrs.bgcolor = crate::color::Color::Idx((n as u8) - 40); @@ -482,6 +485,17 @@ impl State { _ => {} } } + 49 => { + self.attrs.bgcolor = crate::color::Color::Default; + } + n if n >= 90 && n <= 97 => { + self.attrs.fgcolor = + crate::color::Color::Idx(n as u8 - 82); + } + n if n >= 100 && n <= 107 => { + self.attrs.bgcolor = + crate::color::Color::Idx(n as u8 - 92); + } _ => {} } i += 1; diff --git a/tests/attr.rs b/tests/attr.rs index cae7555..2cc94ba 100644 --- a/tests/attr.rs +++ b/tests/attr.rs @@ -110,6 +110,33 @@ fn colors() { assert_eq!(screen.cell(0, 1).unwrap().fgcolor(), vt100::Color::Idx(2)); assert_eq!(screen.cell(0, 1).unwrap().bgcolor(), vt100::Color::Idx(7)); + + screen.process(b"\x1b[2J\x1b[H"); + screen.process(b"\x1b[39mfoo"); + + assert_eq!(screen.fgcolor(), vt100::Color::Default); + assert_eq!(screen.bgcolor(), vt100::Color::Idx(7)); + + assert_eq!(screen.cell(0, 1).unwrap().fgcolor(), vt100::Color::Default); + assert_eq!(screen.cell(0, 1).unwrap().bgcolor(), vt100::Color::Idx(7)); + + screen.process(b"\x1b[2J\x1b[H"); + screen.process(b"\x1b[49mfoo"); + + assert_eq!(screen.fgcolor(), vt100::Color::Default); + assert_eq!(screen.bgcolor(), vt100::Color::Default); + + assert_eq!(screen.cell(0, 1).unwrap().fgcolor(), vt100::Color::Default); + assert_eq!(screen.cell(0, 1).unwrap().bgcolor(), vt100::Color::Default); + + screen.process(b"\x1b[m\x1b[2J\x1b[H"); + screen.process(b"\x1b[92;107mfoo"); + + assert_eq!(screen.fgcolor(), vt100::Color::Idx(10)); + assert_eq!(screen.bgcolor(), vt100::Color::Idx(15)); + + assert_eq!(screen.cell(0, 1).unwrap().fgcolor(), vt100::Color::Idx(10)); + assert_eq!(screen.cell(0, 1).unwrap().bgcolor(), vt100::Color::Idx(15)); } #[test] |