From 2903b1024717af8beb5ce7ab7b3a1b7bbeeec813 Mon Sep 17 00:00:00 2001 From: FAlexei <139798315+FAlexei@users.noreply.github.com> Date: Sun, 14 Apr 2024 12:25:40 +0300 Subject: [PATCH 1/5] Russian translation update --- i18n/ru/cosmic_term.ftl | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/i18n/ru/cosmic_term.ftl b/i18n/ru/cosmic_term.ftl index 5abde5e..9c947ee 100644 --- a/i18n/ru/cosmic_term.ftl +++ b/i18n/ru/cosmic_term.ftl @@ -1,5 +1,29 @@ +cosmic-terminal = Терминал COSMIC +new-terminal = Новый терминал + # Context Pages +## About +git-description = Git-коммит {$hash} от {$date} + +## Color schemes +color-schemes = Цветовые схемы +rename = Переименовать +export = Экспортировать +delete = Удалить +import = Импортировать +import-errors = Ошибки при импорте + +## Profiles +profiles = Профили +name = Имя +command-line = Командная строка +tab-title = Заголовок вкладки +tab-title-description = Переопределить заголовок вкладки по умолчанию +add-profile = Добавить профиль +new-profile = Новый профиль +make-default = Установить по умолчанию + ## Settings settings = Параметры @@ -12,6 +36,7 @@ light = Светлая syntax-dark = Цветовая схема темная syntax-light = Цветовая схема светлая default-zoom-step = Шаги масштабирования +opacity = Прозрачность фона ### Font font = Шрифт @@ -44,6 +69,8 @@ find-next = Найти далее file = Файл new-tab = Новая вкладка new-window = Новое окно +profile = Профиль +menu-profiles = Профили... close-tab = Закрыть вкладку quit = Завершить @@ -64,4 +91,6 @@ previous-tab = Предыдущая вкладка split-horizontal = Разделение по горизонтали split-vertical = Разделение по вертикали pane-toggle-maximize = Переключить на весь экран +menu-color-schemes = Цветовые схемы... menu-settings = Параметры... +menu-about = О Терминале COSMIC... From c63e19eea37b2e39626da1b7618d79e1b17922af Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Fri, 12 Apr 2024 13:26:08 +0200 Subject: [PATCH 2/5] Add fallback if selected color theme is not present The fallback is the first available theme when sorted, this is to make things predictable and to get the same theme if you open the terminal multiple times --- src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e5597da..15e1ded 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1135,7 +1135,15 @@ impl App { self.pane_model.focus = pane; match &self.term_event_tx_opt { Some(term_event_tx) => { - match self.themes.get(&self.config.syntax_theme(profile_id_opt)) { + let colors = self + .themes + .get(&self.config.syntax_theme(profile_id_opt)) + .or_else(|| { + let mut keys: Vec<_> = self.themes.keys().collect(); + keys.sort_by(|a, b| (&a.0).cmp(&b.0)); + keys.first().and_then(|key| self.themes.get(key)) + }); + match colors { Some(colors) => { let current_pane = self.pane_model.focus; if let Some(tab_model) = self.pane_model.active_mut() { From 3e41d261a9d5d2284cd6ae85acde2562b8a5ccd6 Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Sun, 14 Apr 2024 16:48:13 +0200 Subject: [PATCH 3/5] Use COSMIC Default themes as fallback --- src/config.rs | 10 ++++++---- src/main.rs | 12 ++++++++---- src/terminal_theme.rs | 8 +++++--- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/config.rs b/src/config.rs index 1e1049a..144c3eb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -14,6 +14,8 @@ use std::sync::OnceLock; use crate::fl; 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)] pub enum AppTheme { @@ -193,8 +195,8 @@ impl Default for Profile { Self { name: fl!("new-profile"), command: String::new(), - syntax_theme_dark: "COSMIC Dark".to_string(), - syntax_theme_light: "COSMIC Light".to_string(), + syntax_theme_dark: COSMIC_THEME_DARK.to_string(), + syntax_theme_light: COSMIC_THEME_LIGHT.to_string(), tab_title: String::new(), } } @@ -239,8 +241,8 @@ impl Default for Config { opacity: 100, profiles: BTreeMap::new(), show_headerbar: true, - syntax_theme_dark: "COSMIC Dark".to_string(), - syntax_theme_light: "COSMIC Light".to_string(), + syntax_theme_dark: COSMIC_THEME_DARK.to_string(), + syntax_theme_light: COSMIC_THEME_LIGHT.to_string(), use_bright_bold: false, default_profile: None, } diff --git a/src/main.rs b/src/main.rs index 15e1ded..d3d6633 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1138,10 +1138,14 @@ impl App { let colors = self .themes .get(&self.config.syntax_theme(profile_id_opt)) - .or_else(|| { - let mut keys: Vec<_> = self.themes.keys().collect(); - keys.sort_by(|a, b| (&a.0).cmp(&b.0)); - keys.first().and_then(|key| self.themes.get(key)) + .or_else(|| match self.config.color_scheme_kind() { + ColorSchemeKind::Dark => self + .themes + .get(&(config::COSMIC_THEME_DARK.to_string(), ColorSchemeKind::Dark)), + ColorSchemeKind::Light => self.themes.get(&( + config::COSMIC_THEME_LIGHT.to_string(), + ColorSchemeKind::Light, + )), }); match colors { Some(colors) => { diff --git a/src/terminal_theme.rs b/src/terminal_theme.rs index 329e5c2..a2e1b80 100644 --- a/src/terminal_theme.rs +++ b/src/terminal_theme.rs @@ -6,7 +6,9 @@ use hex_color::HexColor; use palette::{encoding::Srgb, rgb::Rgb as PRgb, FromColor, Okhsl}; 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. #[allow(dead_code)] @@ -338,11 +340,11 @@ fn cosmic_light() -> Colors { pub fn terminal_themes() -> HashMap<(String, ColorSchemeKind), Colors> { let mut themes = HashMap::new(); themes.insert( - ("COSMIC Dark".to_string(), ColorSchemeKind::Dark), + (COSMIC_THEME_DARK.to_string(), ColorSchemeKind::Dark), cosmic_dark(), ); themes.insert( - ("COSMIC Light".to_string(), ColorSchemeKind::Light), + (COSMIC_THEME_LIGHT.to_string(), ColorSchemeKind::Light), cosmic_light(), ); themes From 38d6ca4ac81baac8e3ee7c1b2e17992806620f39 Mon Sep 17 00:00:00 2001 From: Mattias Eriksson Date: Mon, 15 Apr 2024 08:10:42 +0200 Subject: [PATCH 4/5] Update swedish translation --- i18n/sv-SE/cosmic_term.ftl | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/i18n/sv-SE/cosmic_term.ftl b/i18n/sv-SE/cosmic_term.ftl index 30a14a2..445e1c1 100644 --- a/i18n/sv-SE/cosmic_term.ftl +++ b/i18n/sv-SE/cosmic_term.ftl @@ -1,9 +1,33 @@ -# Context sidor +cosmic-terminal = COSMIC Terminal +new-terminal = Ny terminal -## Settings +# Context Pages + +## Om +git-description = Git commit {$hash} på {$date} + +## Färgscheman +color-schemes = Färgscheman +rename = Byt namn +export = Exportera +delete = Ta bort +import = Importera +import-errors = Fel vid import + +## Profiler +profiles = Profiler +name = Namn +command-line = Kommandorad +tab-title = Titel på flik +tab-title-description = Åsidosätt standardtitel för flik +add-profile = Lägg till profil +new-profile = Ny profil +make-default = Gör till standard + +## Inställningar settings = Inställningar -### Appearance +### Utseende appearance = Utseende theme = Tema match-desktop = Matcha skrivbordet @@ -12,6 +36,7 @@ light = Ljust syntax-dark = Färgschema mörkt syntax-light = Färgschema ljust default-zoom-step = Zoom steg +opacity = Bakgrundens opacitet ### Teckensnitt font = Teckensnitt @@ -44,6 +69,8 @@ find-next = Hitta nästa file = Fil new-tab = Ny flik new-window = Nytt fönster +profile = Profil +menu-profiles = Profiler… close-tab = Stäng flik quit = Avsluta @@ -64,4 +91,6 @@ previous-tab = Föregående flik split-horizontal = Dela horisontellt split-vertical = Dela vertikalt pane-toggle-maximize = Växla maximerad +menu-color-schemes = Färgscheman… menu-settings = Inställningar… +menu-about = Om COSMIC Terminal… From 7c5d5440e5a560238de3666d7ead6970477a7dd6 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 19 Apr 2024 14:09:32 -0600 Subject: [PATCH 5/5] terminal: always call update_colors on set_config --- src/terminal.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/terminal.rs b/src/terminal.rs index ab040ca..ba72435 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -572,11 +572,14 @@ impl Terminal { } } if changed { - self.update_colors(config); update = true; } } + //TODO: this is done on every set_config because the changed boolean above does not capture + // WINDOW_BG changes + self.update_colors(config); + if update_cell_size { self.update_cell_size(); } else if update {