pub struct Palette {
pub enabled: bool,
pub key: &'static str,
pub title: &'static str,
pub sep: &'static str,
}
impl Palette {
pub fn new(enabled: bool) -> Self {
Palette {
enabled,
key: "38;2;149;128;255",
title: "1;38;2;149;128;255",
sep: "38;2;121;112;169",
}
}
pub fn paint(&self, sgr: &str, text: &str) -> String {
if self.enabled && !sgr.is_empty() {
format!("\x1b[{sgr}m{text}\x1b[0m")
} else {
text.to_string()
}
}
}