diff options
| author | sigoden <sigoden@gmail.com> | 2023-10-30 11:45:07 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-30 11:45:07 +0800 |
| commit | f2c9f00bda1e69306bb2b73843ed7a95cd703bb5 (patch) | |
| tree | 19d1266a7a532f48e22e878fe8420710be6d9ede /src/config/mod.rs | |
| parent | b3e687943811fd48589d7030122c33c7e9867ec9 (diff) | |
| download | aichat-f2c9f00bda1e69306bb2b73843ed7a95cd703bb5.tar.gz | |
fix: detect light theme only by env var (#177)
Diffstat (limited to 'src/config/mod.rs')
| -rw-r--r-- | src/config/mod.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 0af432c..ed256e6 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -10,7 +10,7 @@ use crate::client::openai::{OpenAIClient, OpenAIConfig}; use crate::client::{all_clients, create_client_config, list_models, ClientConfig, ModelInfo}; use crate::config::message::num_tokens_from_messages; use crate::render::RenderOptions; -use crate::utils::{get_env_name, now}; +use crate::utils::{get_env_name, light_theme_from_colorfgbg, now}; use anyhow::{anyhow, bail, Context, Result}; use inquire::{Confirm, Select, Text}; @@ -592,13 +592,11 @@ impl Config { if let Ok(value) = env::var(get_env_name("light_theme")) { set_bool(&mut self.light_theme, &value); return Ok(()); - } - #[cfg(not(target_os = "windows"))] - if let Ok(crate::utils::termbg::Theme::Light) = - crate::utils::termbg::theme(std::time::Duration::from_millis(200)) - { - self.light_theme = true; - } + } else if let Ok(value) = env::var("COLORFGBG") { + if let Some(light) = light_theme_from_colorfgbg(&value) { + self.light_theme = light + } + }; Ok(()) } |
