diff options
author | Joe Wilm <joe@jwilm.com> | 2016-12-04 13:13:44 -0800 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2016-12-11 20:23:41 -0800 |
commit | ce32eee0999b60842c63cb7607b8bf9319242d5c (patch) | |
tree | bfe30ba3464800d2ba109c82bd67ede4b0268e71 /src/ansi.rs | |
parent | 23e36f19255db60084c2c240a166d137f6c12c3e (diff) | |
download | alacritty-ce32eee0999b60842c63cb7607b8bf9319242d5c.tar.gz alacritty-ce32eee0999b60842c63cb7607b8bf9319242d5c.zip |
Refactor color list management
There's now a ColorList type that provides strongly typed indexing for
not only usize but NamedColor as well. Previously, the `NamedColor` was
casted to a `usize` when indexing the colors. Additionally, only one
copy of the ColorList needs to exist;it's borrowed from the `Config`
when rendering, and the renderer doesn't need a copy.
Diffstat (limited to 'src/ansi.rs')
-rw-r--r-- | src/ansi.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/ansi.rs b/src/ansi.rs index 089bc277..8ff0a2e4 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -349,6 +349,22 @@ pub enum NamedColor { Background, } +impl NamedColor { + pub fn to_bright(&self) -> Self { + match *self { + NamedColor::Black => NamedColor::BrightBlack, + NamedColor::Red => NamedColor::BrightRed, + NamedColor::Green => NamedColor::BrightGreen, + NamedColor::Yellow => NamedColor::BrightYellow, + NamedColor::Blue => NamedColor::BrightBlue, + NamedColor::Magenta => NamedColor::BrightMagenta, + NamedColor::Cyan => NamedColor::BrightCyan, + NamedColor::White => NamedColor::BrightWhite, + val => val + } + } +} + #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum Color { Named(NamedColor), |