Fixing color schemes
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use ratatui::style::{Modifier, Style};
|
||||
|
||||
use crate::model::{SourceSpan, WordCompile, WORDS};
|
||||
use crate::theme::syntax;
|
||||
use crate::theme;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
pub enum TokenKind {
|
||||
@@ -25,23 +25,24 @@ pub enum TokenKind {
|
||||
|
||||
impl TokenKind {
|
||||
pub fn style(self) -> Style {
|
||||
let theme = theme::get();
|
||||
let (fg, bg) = match self {
|
||||
TokenKind::Emit => syntax::EMIT,
|
||||
TokenKind::Number => syntax::NUMBER,
|
||||
TokenKind::String => syntax::STRING,
|
||||
TokenKind::Comment => syntax::COMMENT,
|
||||
TokenKind::Keyword => syntax::KEYWORD,
|
||||
TokenKind::StackOp => syntax::STACK_OP,
|
||||
TokenKind::Operator => syntax::OPERATOR,
|
||||
TokenKind::Sound => syntax::SOUND,
|
||||
TokenKind::Param => syntax::PARAM,
|
||||
TokenKind::Context => syntax::CONTEXT,
|
||||
TokenKind::Note => syntax::NOTE,
|
||||
TokenKind::Interval => syntax::INTERVAL,
|
||||
TokenKind::Variable => syntax::VARIABLE,
|
||||
TokenKind::Vary => syntax::VARY,
|
||||
TokenKind::Generator => syntax::GENERATOR,
|
||||
TokenKind::Default => syntax::DEFAULT,
|
||||
TokenKind::Emit => theme.syntax.emit,
|
||||
TokenKind::Number => theme.syntax.number,
|
||||
TokenKind::String => theme.syntax.string,
|
||||
TokenKind::Comment => theme.syntax.comment,
|
||||
TokenKind::Keyword => theme.syntax.keyword,
|
||||
TokenKind::StackOp => theme.syntax.stack_op,
|
||||
TokenKind::Operator => theme.syntax.operator,
|
||||
TokenKind::Sound => theme.syntax.sound,
|
||||
TokenKind::Param => theme.syntax.param,
|
||||
TokenKind::Context => theme.syntax.context,
|
||||
TokenKind::Note => theme.syntax.note,
|
||||
TokenKind::Interval => theme.syntax.interval,
|
||||
TokenKind::Variable => theme.syntax.variable,
|
||||
TokenKind::Vary => theme.syntax.vary,
|
||||
TokenKind::Generator => theme.syntax.generator,
|
||||
TokenKind::Default => theme.syntax.default,
|
||||
};
|
||||
let style = Style::default().fg(fg).bg(bg);
|
||||
if matches!(self, TokenKind::Emit) {
|
||||
@@ -52,7 +53,8 @@ impl TokenKind {
|
||||
}
|
||||
|
||||
pub fn gap_style() -> Style {
|
||||
Style::default().bg(syntax::GAP_BG)
|
||||
let theme = theme::get();
|
||||
Style::default().bg(theme.syntax.gap_bg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,10 +225,11 @@ pub fn highlight_line_with_runtime(
|
||||
if token.varargs {
|
||||
style = style.add_modifier(Modifier::UNDERLINED);
|
||||
}
|
||||
let theme = theme::get();
|
||||
if is_selected {
|
||||
style = style.bg(syntax::SELECTED_BG).add_modifier(Modifier::BOLD);
|
||||
style = style.bg(theme.syntax.selected_bg).add_modifier(Modifier::BOLD);
|
||||
} else if is_executed {
|
||||
style = style.bg(syntax::EXECUTED_BG);
|
||||
style = style.bg(theme.syntax.executed_bg);
|
||||
}
|
||||
|
||||
result.push((style, line[token.start..token.end].to_string()));
|
||||
|
||||
Reference in New Issue
Block a user