use std::borrow::Cow;
use crate::themes::Theme;
use crossterm::style::Stylize;
#[derive(Default, Debug, Clone, Copy)]
pub struct ArrowsColorTheme {}
impl Theme for ArrowsColorTheme {
fn highlight_insert<'this>(&self, input: &'this str) -> Cow<'this, str> {
input.underlined().to_string().into()
}
fn highlight_delete<'this>(&self, input: &'this str) -> Cow<'this, str> {
input.underlined().to_string().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 header<'this>(&self) -> Cow<'this, str> {
format!("{} / {}\n", "< left".red(), "> right".green()).into()
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::borrow::Cow;
#[test]
fn test_arrows_color_theme_prefixes() {
let theme = ArrowsColorTheme::default();
assert_eq!(theme.equal_prefix(), Cow::Borrowed(" "));
assert!(theme.delete_prefix().contains('<'));
assert!(theme.insert_prefix().contains('>'));
}
#[test]
fn test_arrows_color_theme_highlighting() {
let theme = ArrowsColorTheme::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));
}
}