use ratatui::style::Color;
fn blend_bg_surface(bg: Color, surface: Color) -> Color {
match (bg, surface) {
(Color::Rgb(br, bg_g, bb), Color::Rgb(sr, sg, sb)) => {
#[allow(clippy::cast_possible_truncation)]
let lerp = |a: u8, b: u8| -> u8 { ((u16::from(a) * 3 + u16::from(b) * 7) / 10) as u8 };
Color::Rgb(lerp(br, sr), lerp(bg_g, sg), lerp(bb, sb))
}
_ => surface,
}
}
pub trait Theme: Send + Sync {
fn name(&self) -> &str;
fn id(&self) -> &str;
fn accent(&self) -> Color;
fn accent_dim(&self) -> Color;
fn text(&self) -> Color;
fn text_dim(&self) -> Color;
fn text_bright(&self) -> Color;
fn success(&self) -> Color;
fn error(&self) -> Color;
fn warning(&self) -> Color;
fn info(&self) -> Color;
fn diff_added(&self) -> Color;
fn diff_removed(&self) -> Color;
fn diff_context(&self) -> Color;
fn border(&self) -> Color;
fn surface(&self) -> Color;
fn background(&self) -> Color {
Color::Reset
}
fn stripe(&self) -> Color {
blend_bg_surface(self.background(), self.surface())
}
fn block_file_read(&self) -> Color {
self.text_dim()
}
fn block_file_edit(&self) -> Color {
self.diff_added()
}
fn block_command(&self) -> Color {
self.text_bright()
}
fn block_thinking(&self) -> Color {
self.text_dim()
}
fn block_pass(&self) -> Color {
self.success()
}
fn block_fail(&self) -> Color {
self.error()
}
fn block_system(&self) -> Color {
self.text_dim()
}
fn indicator_pending(&self) -> Color {
self.text_dim()
}
fn indicator_running(&self) -> Color {
self.warning()
}
fn indicator_passed(&self) -> Color {
self.success()
}
fn indicator_failed(&self) -> Color {
self.error()
}
fn indicator_skipped(&self) -> Color {
self.text_dim()
}
}