leetcode_tui_config/
theme.rs

1pub mod color;
2pub mod style;
3
4use crate::theme::style::Style;
5use serde::{Deserialize, Serialize};
6
7use self::color::Color;
8
9#[derive(Serialize, Debug, Deserialize)]
10pub struct Difficulty {
11    pub easy: Style,
12    pub medium: Style,
13    pub hard: Style,
14}
15
16#[derive(Serialize, Debug, Deserialize)]
17pub struct Question {
18    pub normal: Difficulty,
19    pub hovered: Difficulty,
20}
21
22#[derive(Serialize, Debug, Deserialize)]
23pub struct Topic {
24    pub normal: Style,
25    pub hovered: Style,
26}
27
28#[derive(Serialize, Debug, Deserialize)]
29pub struct Border {
30    pub normal: Style,
31    pub hovered: Style,
32}
33
34#[derive(Serialize, Debug, Deserialize)]
35pub struct Defaults {
36    pub bg_dark: Color,
37    pub bg: Color,
38    pub bg_highlight: Color,
39    pub terminal_black: Color,
40    pub fg: Color,
41    pub fg_dark: Color,
42    pub fg_gutter: Color,
43    pub dark3: Color,
44    pub comment: Color,
45    pub dark5: Color,
46    pub info: Color,
47}
48
49#[derive(Serialize, Debug, Deserialize)]
50pub struct Theme {
51    pub question: Question,
52    pub topic: Topic,
53    pub border: Border,
54    pub defaults: Defaults,
55}
56
57impl Default for Theme {
58    fn default() -> Self {
59        toml::from_str(
60            r#"
61            [question.normal]
62            easy = { fg = '#9ece6a' }
63            medium = { fg = '#e0af68' }
64            hard = { fg = '#f7768e' }
65
66            [question.hovered]
67            easy = { fg = '#9ece6a', bg = '#292e42', bold = true }
68            medium = { fg = '#e0af68', bg = '#292e42', bold = true }
69            hard = { fg = '#f7768e', bg = '#292e42', bold = true }
70
71            [topic]
72            normal = { fg = '#a9b1d6' }
73            hovered = { fg = '#c0caf5', bg = '#292e42', bold = true }
74
75            [border]
76            hovered = { fg = '#7dcfff', bold = true }
77            normal = { fg = '#a9b1d6' }
78
79            [defaults]
80            bg_dark = '#1f2335'
81            bg = '#24283b'
82            bg_highlight = '#292e42'
83            terminal_black = '#414868'
84            fg = '#c0caf5'
85            fg_dark = '#a9b1d6'
86            fg_gutter = '#3b4261'
87            dark3 = '#545c7e'
88            comment = '#565f89'
89            dark5 = '#737aa2'
90            info = '#7dcfff'
91        "#,
92        )
93        .unwrap()
94    }
95}