Merge branch 'master' into primary

This commit is contained in:
Mattias Eriksson 2024-04-25 11:02:38 +02:00
commit 47689a58bf
6 changed files with 89 additions and 12 deletions

View file

@ -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...

View file

@ -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…

View file

@ -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,
}

View file

@ -1143,7 +1143,19 @@ 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(|| 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) => {
let current_pane = self.pane_model.focus;
if let Some(tab_model) = self.pane_model.active_mut() {

View file

@ -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 {

View file

@ -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