Use COSMIC Default themes as fallback
This commit is contained in:
parent
c63e19eea3
commit
3e41d261a9
3 changed files with 19 additions and 11 deletions
|
|
@ -14,6 +14,8 @@ use std::sync::OnceLock;
|
||||||
use crate::fl;
|
use crate::fl;
|
||||||
|
|
||||||
pub const CONFIG_VERSION: u64 = 1;
|
pub const CONFIG_VERSION: u64 = 1;
|
||||||
|
pub const COSMIC_THEME_DARK: &str = "COSMIC Dark";
|
||||||
|
pub const COSMIC_THEME_LIGHT: &str = "COSMIC Light";
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
|
||||||
pub enum AppTheme {
|
pub enum AppTheme {
|
||||||
|
|
@ -193,8 +195,8 @@ impl Default for Profile {
|
||||||
Self {
|
Self {
|
||||||
name: fl!("new-profile"),
|
name: fl!("new-profile"),
|
||||||
command: String::new(),
|
command: String::new(),
|
||||||
syntax_theme_dark: "COSMIC Dark".to_string(),
|
syntax_theme_dark: COSMIC_THEME_DARK.to_string(),
|
||||||
syntax_theme_light: "COSMIC Light".to_string(),
|
syntax_theme_light: COSMIC_THEME_LIGHT.to_string(),
|
||||||
tab_title: String::new(),
|
tab_title: String::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -239,8 +241,8 @@ impl Default for Config {
|
||||||
opacity: 100,
|
opacity: 100,
|
||||||
profiles: BTreeMap::new(),
|
profiles: BTreeMap::new(),
|
||||||
show_headerbar: true,
|
show_headerbar: true,
|
||||||
syntax_theme_dark: "COSMIC Dark".to_string(),
|
syntax_theme_dark: COSMIC_THEME_DARK.to_string(),
|
||||||
syntax_theme_light: "COSMIC Light".to_string(),
|
syntax_theme_light: COSMIC_THEME_LIGHT.to_string(),
|
||||||
use_bright_bold: false,
|
use_bright_bold: false,
|
||||||
default_profile: None,
|
default_profile: None,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
src/main.rs
12
src/main.rs
|
|
@ -1138,10 +1138,14 @@ impl App {
|
||||||
let colors = self
|
let colors = self
|
||||||
.themes
|
.themes
|
||||||
.get(&self.config.syntax_theme(profile_id_opt))
|
.get(&self.config.syntax_theme(profile_id_opt))
|
||||||
.or_else(|| {
|
.or_else(|| match self.config.color_scheme_kind() {
|
||||||
let mut keys: Vec<_> = self.themes.keys().collect();
|
ColorSchemeKind::Dark => self
|
||||||
keys.sort_by(|a, b| (&a.0).cmp(&b.0));
|
.themes
|
||||||
keys.first().and_then(|key| self.themes.get(key))
|
.get(&(config::COSMIC_THEME_DARK.to_string(), ColorSchemeKind::Dark)),
|
||||||
|
ColorSchemeKind::Light => self.themes.get(&(
|
||||||
|
config::COSMIC_THEME_LIGHT.to_string(),
|
||||||
|
ColorSchemeKind::Light,
|
||||||
|
)),
|
||||||
});
|
});
|
||||||
match colors {
|
match colors {
|
||||||
Some(colors) => {
|
Some(colors) => {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,9 @@ use hex_color::HexColor;
|
||||||
use palette::{encoding::Srgb, rgb::Rgb as PRgb, FromColor, Okhsl};
|
use palette::{encoding::Srgb, rgb::Rgb as PRgb, FromColor, Okhsl};
|
||||||
use std::{collections::HashMap, fs};
|
use std::{collections::HashMap, fs};
|
||||||
|
|
||||||
use crate::config::{ColorScheme, ColorSchemeAnsi, ColorSchemeKind};
|
use crate::config::{
|
||||||
|
ColorScheme, ColorSchemeAnsi, ColorSchemeKind, COSMIC_THEME_DARK, COSMIC_THEME_LIGHT,
|
||||||
|
};
|
||||||
|
|
||||||
// Fill missing dim/bright colors with derived values from normal ones.
|
// Fill missing dim/bright colors with derived values from normal ones.
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
@ -338,11 +340,11 @@ fn cosmic_light() -> Colors {
|
||||||
pub fn terminal_themes() -> HashMap<(String, ColorSchemeKind), Colors> {
|
pub fn terminal_themes() -> HashMap<(String, ColorSchemeKind), Colors> {
|
||||||
let mut themes = HashMap::new();
|
let mut themes = HashMap::new();
|
||||||
themes.insert(
|
themes.insert(
|
||||||
("COSMIC Dark".to_string(), ColorSchemeKind::Dark),
|
(COSMIC_THEME_DARK.to_string(), ColorSchemeKind::Dark),
|
||||||
cosmic_dark(),
|
cosmic_dark(),
|
||||||
);
|
);
|
||||||
themes.insert(
|
themes.insert(
|
||||||
("COSMIC Light".to_string(), ColorSchemeKind::Light),
|
(COSMIC_THEME_LIGHT.to_string(), ColorSchemeKind::Light),
|
||||||
cosmic_light(),
|
cosmic_light(),
|
||||||
);
|
);
|
||||||
themes
|
themes
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue