use crate::highlight::TokenKind;
use ratatui::style::Color;
pub const DIR: Color = Color::Rgb(96, 165, 250);
pub const IMAGE: Color = Color::Rgb(196, 160, 250);
pub const VIDEO: Color = Color::Rgb(244, 114, 182);
pub const PDF: Color = Color::Rgb(248, 113, 113);
pub const SHEET: Color = Color::Rgb(74, 222, 128);
pub const DOC: Color = Color::Rgb(252, 211, 77);
pub const CODE: Color = Color::Rgb(134, 239, 172);
pub const ARCHIVE: Color = Color::Rgb(251, 146, 60);
pub const OTHER: Color = Color::Rgb(205, 205, 215);
pub const DIM: Color = Color::Rgb(120, 120, 132);
pub const ACCENT: Color = Color::Rgb(125, 211, 252);
pub fn token_color(kind: TokenKind) -> Color {
match kind {
TokenKind::Keyword => Color::Rgb(147, 197, 253), TokenKind::Str => DOC, TokenKind::Comment => DIM,
TokenKind::Number => IMAGE, TokenKind::Plain => OTHER,
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn token_kinds_map_to_distinct_colors() {
let colors = [
token_color(TokenKind::Keyword),
token_color(TokenKind::Str),
token_color(TokenKind::Comment),
token_color(TokenKind::Number),
token_color(TokenKind::Plain),
];
for i in 0..colors.len() {
for j in (i + 1)..colors.len() {
assert_ne!(colors[i], colors[j], "colours {i} and {j} collide");
}
}
}
}