diff options
author | Jesse Luehrs <doy@tozt.net> | 2016-04-27 02:36:30 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2016-04-27 03:03:46 -0400 |
commit | df328c13903d5a0e595d27b14f79e2a61f66f8fc (patch) | |
tree | 84812f3b90cd60a38a461e1b33e059365309492c /src/color.rs | |
parent | 65b2ce10f83942a9dd2974ac19c694f1c6c9e617 (diff) | |
download | vt100-rust-df328c13903d5a0e595d27b14f79e2a61f66f8fc.tar.gz vt100-rust-df328c13903d5a0e595d27b14f79e2a61f66f8fc.zip |
implement fgcolor and bgcolor for cells
Diffstat (limited to 'src/color.rs')
-rw-r--r-- | src/color.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/color.rs b/src/color.rs new file mode 100644 index 0000000..52d9d61 --- /dev/null +++ b/src/color.rs @@ -0,0 +1,23 @@ +use std; + +use types; + +#[derive(Eq,PartialEq,Debug)] +pub enum Color { + ColorDefault, + ColorIdx(u8), + ColorRgb(u8, u8, u8), +} + +impl Color { + pub fn new(color_impl: &types::ColorImpl) -> Color { + let &types::ColorImpl(color_repr) = color_impl; + let bytes: [u8; 4] = unsafe { std::mem::transmute(color_repr) }; + match bytes[3] { + 0 => Color::ColorDefault, + 1 => Color::ColorIdx(bytes[0]), + 2 => Color::ColorRgb(bytes[0], bytes[1], bytes[2]), + _ => panic!("invalid color type"), + } + } +} |