ratatui_toolkit/services/theme/loader/
load_builtin.rs1use crate::services::theme::app_theme::AppTheme;
4use crate::services::theme::loader::load_theme_str::load_theme_str;
5use crate::services::theme::ThemeVariant;
6
7pub const BUILTIN_THEMES: &[&str] = &[
12 "aura",
13 "ayu",
14 "carbonfox",
15 "catppuccin",
16 "catppuccin-frappe",
17 "catppuccin-macchiato",
18 "cobalt2",
19 "cursor",
20 "dracula",
21 "everforest",
22 "flexoki",
23 "github",
24 "gruvbox",
25 "kanagawa",
26 "lucent-orng",
27 "material",
28 "matrix",
29 "mercury",
30 "monokai",
31 "nightowl",
32 "nord",
33 "one-dark",
34 "orng",
35 "osaka-jade",
36 "palenight",
37 "rosepine",
38 "solarized",
39 "synthwave84",
40 "tokyonight",
41 "vercel",
42 "vesper",
43 "zenburn",
44];
45
46pub fn load_builtin_theme(name: &str, variant: ThemeVariant) -> Result<AppTheme, String> {
70 let json = get_builtin_theme_json(name)?;
71 load_theme_str(json, variant)
72}
73
74fn get_builtin_theme_json(name: &str) -> Result<&'static str, String> {
76 match name {
77 "aura" => Ok(include_str!("../themes/aura.json")),
78 "ayu" => Ok(include_str!("../themes/ayu.json")),
79 "carbonfox" => Ok(include_str!("../themes/carbonfox.json")),
80 "catppuccin" => Ok(include_str!("../themes/catppuccin.json")),
81 "catppuccin-frappe" => Ok(include_str!("../themes/catppuccin-frappe.json")),
82 "catppuccin-macchiato" => Ok(include_str!("../themes/catppuccin-macchiato.json")),
83 "cobalt2" => Ok(include_str!("../themes/cobalt2.json")),
84 "cursor" => Ok(include_str!("../themes/cursor.json")),
85 "dracula" => Ok(include_str!("../themes/dracula.json")),
86 "everforest" => Ok(include_str!("../themes/everforest.json")),
87 "flexoki" => Ok(include_str!("../themes/flexoki.json")),
88 "github" => Ok(include_str!("../themes/github.json")),
89 "gruvbox" => Ok(include_str!("../themes/gruvbox.json")),
90 "kanagawa" => Ok(include_str!("../themes/kanagawa.json")),
91 "lucent-orng" => Ok(include_str!("../themes/lucent-orng.json")),
92 "material" => Ok(include_str!("../themes/material.json")),
93 "matrix" => Ok(include_str!("../themes/matrix.json")),
94 "mercury" => Ok(include_str!("../themes/mercury.json")),
95 "monokai" => Ok(include_str!("../themes/monokai.json")),
96 "nightowl" => Ok(include_str!("../themes/nightowl.json")),
97 "nord" => Ok(include_str!("../themes/nord.json")),
98 "one-dark" => Ok(include_str!("../themes/one-dark.json")),
99 "orng" => Ok(include_str!("../themes/orng.json")),
100 "osaka-jade" => Ok(include_str!("../themes/osaka-jade.json")),
101 "palenight" => Ok(include_str!("../themes/palenight.json")),
102 "rosepine" => Ok(include_str!("../themes/rosepine.json")),
103 "solarized" => Ok(include_str!("../themes/solarized.json")),
104 "synthwave84" => Ok(include_str!("../themes/synthwave84.json")),
105 "tokyonight" => Ok(include_str!("../themes/tokyonight.json")),
106 "vercel" => Ok(include_str!("../themes/vercel.json")),
107 "vesper" => Ok(include_str!("../themes/vesper.json")),
108 "zenburn" => Ok(include_str!("../themes/zenburn.json")),
109 _ => Err(format!(
110 "Unknown builtin theme: '{}'. Available themes: {:?}",
111 name, BUILTIN_THEMES
112 )),
113 }
114}