use std::borrow::Cow;
use crate::themes::Theme;
use crossterm::style::Stylize;
#[derive(Default, Clone, Copy, Debug)]
pub struct SignsColorTheme {}
impl Theme for SignsColorTheme {
fn highlight_insert<'this>(&self, input: &'this str) -> Cow<'this, str> {
input.underlined().green().to_string().into()
}
fn highlight_delete<'this>(&self, input: &'this str) -> Cow<'this, str> {
input.underlined().red().to_string().into()
}
fn equal_content<'this>(&self, input: &'this str) -> Cow<'this, str> {
input.into()
}
fn delete_content<'this>(&self, input: &'this str) -> Cow<'this, str> {
input.red().to_string().into()
}
fn equal_prefix<'this>(&self) -> Cow<'this, str> {
" ".into()
}
fn delete_prefix<'this>(&self) -> Cow<'this, str> {
"-".red().to_string().into()
}
fn insert_line<'this>(&self, input: &'this str) -> Cow<'this, str> {
input.green().to_string().into()
}
fn insert_prefix<'this>(&self) -> Cow<'this, str> {
"+".green().to_string().into()
}
fn line_end<'this>(&self) -> Cow<'this, str> {
"\n".into()
}
fn header<'this>(&self) -> Cow<'this, str> {
format!("{} | {}\n", "--- remove".red(), "insert +++".green()).into()
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::borrow::Cow;
#[test]
fn test_signs_color_theme_prefixes() {
let theme = SignsColorTheme::default();
assert_eq!(theme.equal_prefix(), Cow::Borrowed(" "));
assert!(theme.delete_prefix().contains('-'));
assert!(theme.insert_prefix().contains('+'));
}
#[test]
fn test_signs_color_theme_highlighting() {
let theme = SignsColorTheme::default();
let input = "test";
assert_ne!(theme.highlight_insert(input), Cow::Borrowed(input));
assert_ne!(theme.highlight_delete(input), Cow::Borrowed(input));
assert_ne!(theme.delete_content(input), Cow::Borrowed(input));
assert_ne!(theme.insert_line(input), Cow::Borrowed(input));
}
}