diff --git a/client_scheme.txt b/client_scheme.txt deleted file mode 100644 index 9949da0..0000000 --- a/client_scheme.txt +++ /dev/null @@ -1,24 +0,0 @@ -. -├── ./colors.rs -└── components1/ - ├── ./components1/mod.rs - ├── ./components1/models.rs - ├── ./components1/handlers.rs - └── handlers/ - ├── ./components1/handlers/command_line.rs - ├── ./components1/handlers/form.rs - ├── ./components1/handlers/mod.rs - ├── ./components1/handlers/preview_card.rs - └── ./components1/handlers/status_line.rs -├── ./config.rs -├── ./mod.rs -├── ./terminal.rs -├── ./ui.rs -└── ./ui - ├── ./ui/mod.rs - ├── ./ui/models.rs - ├── ./ui/handlers.rs - └── handlers/ - ├── ./ui/handlers/x.rs - ├── ./ui/handlers/x2.rs - └── ./ui/handlers/x3.rs diff --git a/config.toml b/config.toml index 248fa12..d6d3919 100644 --- a/config.toml +++ b/config.toml @@ -13,3 +13,7 @@ move_left = ["h"] move_right = ["l"] move_up = ["k", "Up"] move_down = ["j", "Down"] + +[colors] +theme = "dark" +# Options: "light", "dark", "high_contrast" diff --git a/src/client/colors.rs b/src/client/colors.rs index 698d431..515f252 100644 --- a/src/client/colors.rs +++ b/src/client/colors.rs @@ -13,6 +13,14 @@ pub struct Theme { } impl Theme { + pub fn from_str(theme_name: &str) -> Self { + match theme_name.to_lowercase().as_str() { + "dark" => Self::dark(), + "high_contrast" => Self::high_contrast(), + _ => Self::light(), + } + } + // Default light theme pub fn light() -> Self { Self { diff --git a/src/client/config.rs b/src/client/config.rs index b249b3f..0395742 100644 --- a/src/client/config.rs +++ b/src/client/config.rs @@ -3,9 +3,21 @@ use serde::Deserialize; use std::collections::HashMap; use crossterm::event::{KeyCode, KeyModifiers}; +#[derive(Debug, Deserialize, Default)] +pub struct ColorsConfig { + #[serde(default = "default_theme")] + pub theme: String, +} + +fn default_theme() -> String { + "light".to_string() +} + #[derive(Debug, Deserialize)] pub struct Config { pub keybindings: HashMap>, + #[serde(default)] + pub colors: ColorsConfig, } impl Config { diff --git a/src/client/ui/handlers/ui.rs b/src/client/ui/handlers/ui.rs index 9748227..eb24950 100644 --- a/src/client/ui/handlers/ui.rs +++ b/src/client/ui/handlers/ui.rs @@ -8,7 +8,7 @@ use crate::client::ui::handlers::{event::EventHandler, form::FormState, state::A pub async fn run_ui() -> Result<(), Box> { let config = Config::load()?; let mut app_terminal = AppTerminal::new().await?; - let theme = Theme::dark(); + let theme = Theme::from_str(&config.colors.theme); // Fetch table structure at startup (one-time) // TODO: Later, consider implementing a live update for table structure changes.