use super::types::TokenType;
use crate::style::Color;
#[derive(Debug, Clone)]
pub struct SyntaxTheme {
pub keyword: Color,
pub type_: Color,
pub string: Color,
pub number: Color,
pub comment: Color,
pub function: Color,
pub operator: Color,
pub macro_: Color,
pub attribute: Color,
pub normal: Color,
}
impl Default for SyntaxTheme {
fn default() -> Self {
Self::monokai()
}
}
impl SyntaxTheme {
pub fn monokai() -> Self {
Self {
keyword: Color::rgb(249, 38, 114), type_: Color::rgb(102, 217, 239), string: Color::rgb(230, 219, 116), number: Color::rgb(174, 129, 255), comment: Color::rgb(117, 113, 94), function: Color::rgb(166, 226, 46), operator: Color::rgb(249, 38, 114), macro_: Color::rgb(102, 217, 239), attribute: Color::rgb(174, 129, 255), normal: Color::rgb(248, 248, 242), }
}
pub fn nord() -> Self {
Self {
keyword: Color::rgb(129, 161, 193), type_: Color::rgb(143, 188, 187), string: Color::rgb(163, 190, 140), number: Color::rgb(180, 142, 173), comment: Color::rgb(76, 86, 106), function: Color::rgb(136, 192, 208), operator: Color::rgb(129, 161, 193), macro_: Color::rgb(208, 135, 112), attribute: Color::rgb(180, 142, 173), normal: Color::rgb(236, 239, 244), }
}
pub fn dracula() -> Self {
Self {
keyword: Color::rgb(255, 121, 198), type_: Color::rgb(139, 233, 253), string: Color::rgb(241, 250, 140), number: Color::rgb(189, 147, 249), comment: Color::rgb(98, 114, 164), function: Color::rgb(80, 250, 123), operator: Color::rgb(255, 121, 198), macro_: Color::rgb(255, 184, 108), attribute: Color::rgb(189, 147, 249), normal: Color::rgb(248, 248, 242), }
}
pub fn one_dark() -> Self {
Self {
keyword: Color::rgb(198, 120, 221), type_: Color::rgb(229, 192, 123), string: Color::rgb(152, 195, 121), number: Color::rgb(209, 154, 102), comment: Color::rgb(92, 99, 112), function: Color::rgb(97, 175, 239), operator: Color::rgb(171, 178, 191), macro_: Color::rgb(86, 182, 194), attribute: Color::rgb(209, 154, 102), normal: Color::rgb(171, 178, 191), }
}
pub fn color(&self, token_type: TokenType) -> Color {
match token_type {
TokenType::Normal => self.normal,
TokenType::Keyword => self.keyword,
TokenType::Type => self.type_,
TokenType::String => self.string,
TokenType::Number => self.number,
TokenType::Comment => self.comment,
TokenType::Function => self.function,
TokenType::Operator => self.operator,
TokenType::Macro => self.macro_,
TokenType::Attribute => self.attribute,
}
}
}