mirror of https://github.com/fdehau/tui-rs
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.3 KiB
Rust
78 lines
1.3 KiB
Rust
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
pub enum Color {
|
|
Reset,
|
|
Black,
|
|
Red,
|
|
Green,
|
|
Yellow,
|
|
Magenta,
|
|
Cyan,
|
|
Gray,
|
|
DarkGray,
|
|
LightRed,
|
|
LightGreen,
|
|
LightYellow,
|
|
LightMagenta,
|
|
LightCyan,
|
|
White,
|
|
Rgb(u8, u8, u8),
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
pub enum Modifier {
|
|
Blink,
|
|
Bold,
|
|
CrossedOut,
|
|
Faint,
|
|
Framed,
|
|
Invert,
|
|
Italic,
|
|
NoBlink,
|
|
NoBold,
|
|
NoCrossedOut,
|
|
NoFaint,
|
|
NoInvert,
|
|
NoItalic,
|
|
NoUnderline,
|
|
Reset,
|
|
Underline,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
pub struct Style {
|
|
pub fg: Color,
|
|
pub bg: Color,
|
|
pub modifier: Modifier,
|
|
}
|
|
|
|
impl Default for Style {
|
|
fn default() -> Style {
|
|
Style {
|
|
fg: Color::Reset,
|
|
bg: Color::Reset,
|
|
modifier: Modifier::Reset,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Style {
|
|
pub fn reset(&mut self) {
|
|
self.fg = Color::Reset;
|
|
self.bg = Color::Reset;
|
|
self.modifier = Modifier::Reset;
|
|
}
|
|
|
|
pub fn fg(mut self, color: Color) -> Style {
|
|
self.fg = color;
|
|
self
|
|
}
|
|
pub fn bg(mut self, color: Color) -> Style {
|
|
self.bg = color;
|
|
self
|
|
}
|
|
pub fn modifier(mut self, modifier: Modifier) -> Style {
|
|
self.modifier = modifier;
|
|
self
|
|
}
|
|
}
|