intermodal/src/style.rs
Casey Rodarmor 35a0e8f9b7
Improve torrent display formatting
- Use colors
- Use cut-friendly formatting when not writing to terminal
- Show sizes as number of bytes when not writing to terminal

type: changed
2020-04-07 19:01:03 -07:00

39 lines
757 B
Rust

#[derive(Clone, Copy, Debug)]
pub(crate) struct Style {
active: bool,
}
impl Style {
pub(crate) fn active() -> Self {
Self { active: true }
}
pub(crate) fn inactive() -> Self {
Self { active: false }
}
pub(crate) fn message(self) -> ansi_term::Style {
if self.active {
ansi_term::Style::new().bold()
} else {
ansi_term::Style::new()
}
}
pub(crate) fn error(self) -> ansi_term::Style {
if self.active {
ansi_term::Style::new().fg(ansi_term::Color::Red).bold()
} else {
ansi_term::Style::new()
}
}
pub(crate) fn blue(self) -> ansi_term::Style {
if self.active {
ansi_term::Style::new().fg(ansi_term::Color::Blue)
} else {
ansi_term::Style::new()
}
}
}