Merge remote-tracking branch 'upstream/master' into primary

This commit is contained in:
Mattias Eriksson 2024-03-04 07:56:36 +01:00
commit 63503d53bd
47 changed files with 3639 additions and 1073 deletions

View file

@ -5,6 +5,7 @@ use cosmic::{
theme,
};
use cosmic_text::{Metrics, Stretch, Weight};
use hex_color::HexColor;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
@ -14,7 +15,7 @@ use crate::fl;
pub const CONFIG_VERSION: u64 = 1;
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum AppTheme {
Dark,
Light,
@ -31,6 +32,145 @@ impl AppTheme {
}
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum ColorSchemeKind {
Dark,
Light,
}
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
#[serde(transparent)]
pub struct ColorSchemeId(pub u64);
//TODO: there is a lot of extra code to keep the exported color scheme clean,
//consider how to reduce this
fn de_color_opt<'de, D>(deserializer: D) -> Result<Option<HexColor>, D::Error>
where
D: serde::Deserializer<'de>,
{
let hex_color: HexColor = Deserialize::deserialize(deserializer)?;
Ok(Some(hex_color))
}
fn ser_color_opt<S>(hex_color_opt: &Option<HexColor>, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
use serde::ser::Error as _;
match hex_color_opt {
Some(hex_color) => Serialize::serialize(hex_color, serializer),
None => Err(S::Error::custom("ser_color_opt called with None")),
}
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(default, deny_unknown_fields)]
pub struct ColorSchemeAnsi {
#[serde(
deserialize_with = "de_color_opt",
serialize_with = "ser_color_opt",
skip_serializing_if = "Option::is_none"
)]
pub black: Option<HexColor>,
#[serde(
deserialize_with = "de_color_opt",
serialize_with = "ser_color_opt",
skip_serializing_if = "Option::is_none"
)]
pub red: Option<HexColor>,
#[serde(
deserialize_with = "de_color_opt",
serialize_with = "ser_color_opt",
skip_serializing_if = "Option::is_none"
)]
pub green: Option<HexColor>,
#[serde(
deserialize_with = "de_color_opt",
serialize_with = "ser_color_opt",
skip_serializing_if = "Option::is_none"
)]
pub yellow: Option<HexColor>,
#[serde(
deserialize_with = "de_color_opt",
serialize_with = "ser_color_opt",
skip_serializing_if = "Option::is_none"
)]
pub blue: Option<HexColor>,
#[serde(
deserialize_with = "de_color_opt",
serialize_with = "ser_color_opt",
skip_serializing_if = "Option::is_none"
)]
pub magenta: Option<HexColor>,
#[serde(
deserialize_with = "de_color_opt",
serialize_with = "ser_color_opt",
skip_serializing_if = "Option::is_none"
)]
pub cyan: Option<HexColor>,
#[serde(
deserialize_with = "de_color_opt",
serialize_with = "ser_color_opt",
skip_serializing_if = "Option::is_none"
)]
pub white: Option<HexColor>,
}
impl ColorSchemeAnsi {
pub fn is_empty(&self) -> bool {
self.black.is_none()
&& self.red.is_none()
&& self.green.is_none()
&& self.yellow.is_none()
&& self.blue.is_none()
&& self.magenta.is_none()
&& self.cyan.is_none()
&& self.white.is_none()
}
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
#[serde(default, deny_unknown_fields)]
pub struct ColorScheme {
pub name: String,
#[serde(
deserialize_with = "de_color_opt",
serialize_with = "ser_color_opt",
skip_serializing_if = "Option::is_none"
)]
pub foreground: Option<HexColor>,
#[serde(
deserialize_with = "de_color_opt",
serialize_with = "ser_color_opt",
skip_serializing_if = "Option::is_none"
)]
pub background: Option<HexColor>,
#[serde(
deserialize_with = "de_color_opt",
serialize_with = "ser_color_opt",
skip_serializing_if = "Option::is_none"
)]
pub cursor: Option<HexColor>,
#[serde(
deserialize_with = "de_color_opt",
serialize_with = "ser_color_opt",
skip_serializing_if = "Option::is_none"
)]
pub bright_foreground: Option<HexColor>,
#[serde(
deserialize_with = "de_color_opt",
serialize_with = "ser_color_opt",
skip_serializing_if = "Option::is_none"
)]
pub dim_foreground: Option<HexColor>,
#[serde(skip_serializing_if = "ColorSchemeAnsi::is_empty")]
pub normal: ColorSchemeAnsi,
#[serde(skip_serializing_if = "ColorSchemeAnsi::is_empty")]
pub bright: ColorSchemeAnsi,
#[serde(skip_serializing_if = "ColorSchemeAnsi::is_empty")]
pub dim: ColorSchemeAnsi,
}
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
#[serde(transparent)]
pub struct ProfileId(pub u64);
@ -63,6 +203,8 @@ impl Default for Profile {
#[derive(Clone, CosmicConfigEntry, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct Config {
pub app_theme: AppTheme,
pub color_schemes_dark: BTreeMap<ColorSchemeId, ColorScheme>,
pub color_schemes_light: BTreeMap<ColorSchemeId, ColorScheme>,
pub font_name: String,
pub font_size: u16,
pub font_weight: u16,
@ -77,6 +219,7 @@ pub struct Config {
pub syntax_theme_dark: String,
pub syntax_theme_light: String,
pub focus_follow_mouse: bool,
pub default_profile: Option<ProfileId>,
}
impl Default for Config {
@ -84,6 +227,8 @@ impl Default for Config {
Self {
app_theme: AppTheme::System,
bold_font_weight: Weight::BOLD.0,
color_schemes_dark: BTreeMap::new(),
color_schemes_light: BTreeMap::new(),
dim_font_weight: Weight::NORMAL.0,
focus_follow_mouse: false,
font_name: "Fira Mono".to_string(),
@ -97,11 +242,63 @@ impl Default for Config {
syntax_theme_dark: "COSMIC Dark".to_string(),
syntax_theme_light: "COSMIC Light".to_string(),
use_bright_bold: false,
default_profile: None,
}
}
}
impl Config {
pub fn color_schemes(
&self,
color_scheme_kind: ColorSchemeKind,
) -> &BTreeMap<ColorSchemeId, ColorScheme> {
match color_scheme_kind {
ColorSchemeKind::Dark => &self.color_schemes_dark,
ColorSchemeKind::Light => &self.color_schemes_light,
}
}
pub fn color_schemes_mut(
&mut self,
color_scheme_kind: ColorSchemeKind,
) -> &mut BTreeMap<ColorSchemeId, ColorScheme> {
match color_scheme_kind {
ColorSchemeKind::Dark => &mut self.color_schemes_dark,
ColorSchemeKind::Light => &mut self.color_schemes_light,
}
}
pub fn color_scheme_kind(&self) -> ColorSchemeKind {
if self.app_theme.theme().theme_type.is_dark() {
ColorSchemeKind::Dark
} else {
ColorSchemeKind::Light
}
}
// Get a sorted and adjusted for duplicates list of color scheme names and ids
pub fn color_scheme_names(
&self,
color_scheme_kind: ColorSchemeKind,
) -> Vec<(String, ColorSchemeId)> {
let color_schemes = self.color_schemes(color_scheme_kind);
let mut color_scheme_names =
Vec::<(String, ColorSchemeId)>::with_capacity(color_schemes.len());
for (color_scheme_id, color_scheme) in color_schemes.iter() {
let mut name = color_scheme.name.clone();
let mut copies = 1;
while color_scheme_names.iter().find(|x| x.0 == name).is_some() {
copies += 1;
name = format!("{} ({})", color_scheme.name, copies);
}
color_scheme_names.push((name, *color_scheme_id));
}
color_scheme_names.sort_by(|a, b| lexical_sort::natural_lexical_cmp(&a.0, &b.0));
color_scheme_names
}
fn font_size_adjusted(&self, zoom_adj: i8) -> f32 {
let font_size = f32::from(self.font_size).max(1.0);
let adj = f32::from(zoom_adj);
@ -120,7 +317,7 @@ impl Config {
(self.opacity as f32) / 100.0
}
// Get a sorted and adjusted for duplicates list of profiles names and ids
// Get a sorted and adjusted for duplicates list of profile names and ids
pub fn profile_names(&self) -> Vec<(String, ProfileId)> {
let mut profile_names = Vec::<(String, ProfileId)>::with_capacity(self.profiles.len());
for (profile_id, profile) in self.profiles.iter() {
@ -139,24 +336,20 @@ impl Config {
}
// Get current syntax theme based on dark mode
pub fn syntax_theme(&self, profile_id_opt: Option<ProfileId>) -> &str {
let dark = self.app_theme.theme().theme_type.is_dark();
match profile_id_opt.and_then(|profile_id| self.profiles.get(&profile_id)) {
Some(profile) => {
if dark {
&profile.syntax_theme_dark
} else {
&profile.syntax_theme_light
}
}
None => {
if dark {
&self.syntax_theme_dark
} else {
&self.syntax_theme_light
}
}
}
pub fn syntax_theme(&self, profile_id_opt: Option<ProfileId>) -> (String, ColorSchemeKind) {
let color_scheme_kind = self.color_scheme_kind();
let theme_name = match profile_id_opt.and_then(|profile_id| self.profiles.get(&profile_id))
{
Some(profile) => match color_scheme_kind {
ColorSchemeKind::Dark => profile.syntax_theme_dark.clone(),
ColorSchemeKind::Light => profile.syntax_theme_light.clone(),
},
None => match color_scheme_kind {
ColorSchemeKind::Dark => self.syntax_theme_dark.clone(),
ColorSchemeKind::Light => self.syntax_theme_light.clone(),
},
};
(theme_name, color_scheme_kind)
}
pub fn typed_font_stretch(&self) -> Stretch {

View file

@ -30,11 +30,13 @@ impl IconCache {
};
}
bundle!("dialog-error-symbolic", 16);
bundle!("edit-clear-symbolic", 16);
bundle!("edit-delete-symbolic", 16);
bundle!("list-add-symbolic", 16);
bundle!("go-down-symbolic", 16);
bundle!("go-up-symbolic", 16);
bundle!("view-more-symbolic", 16);
bundle!("window-close-symbolic", 16);
Self { cache }

View file

@ -70,6 +70,7 @@ pub fn key_binds() -> HashMap<KeyBind, Action> {
bind!([Ctrl, Shift], Key::Character("V".into()), Paste);
bind!([Shift], Key::Named(Named::Insert), PastePrimary);
bind!([Ctrl, Shift], Key::Character("W".into()), TabClose);
bind!([Ctrl], Key::Character(",".into()), Settings);
// Ctrl+Alt+D splits horizontally, Ctrl+Alt+R splits vertically, Ctrl+Shift+X maximizes split
//TODO: Adjust bindings as desired by UX

File diff suppressed because it is too large Load diff

View file

@ -17,7 +17,7 @@ use cosmic::{
};
use std::collections::HashMap;
use crate::{fl, Action, Config, KeyBind, Message};
use crate::{fl, Action, ColorSchemeId, ColorSchemeKind, Config, KeyBind, Message};
macro_rules! menu_button {
($($x:expr),+ $(,)?) => (
@ -108,6 +108,42 @@ pub fn context_menu<'a>(
.into()
}
pub fn color_scheme_menu<'a>(
kind: ColorSchemeKind,
id: ColorSchemeId,
name: &str,
) -> Element<'a, Message> {
let menu_item = |label, message| menu_button!(widget::text(label)).on_press(message);
widget::container(column!(
menu_item(
fl!("rename"),
Message::ColorSchemeRename(kind, id, name.to_string())
),
menu_item(fl!("export"), Message::ColorSchemeExport(kind, id)),
menu_item(fl!("delete"), Message::ColorSchemeDelete(kind, id)),
))
.padding(1)
//TODO: move style to libcosmic
.style(theme::Container::custom(|theme| {
let cosmic = theme.cosmic();
let component = &cosmic.background.component;
widget::container::Appearance {
icon_color: Some(component.on.into()),
text_color: Some(component.on.into()),
background: Some(Background::Color(component.base.into())),
border: Border {
radius: 8.0.into(),
width: 1.0,
color: component.divider.into(),
},
..Default::default()
}
}))
.width(Length::Fixed(120.0))
.into()
}
pub fn menu_bar<'a>(config: &Config, key_binds: &HashMap<KeyBind, Action>) -> Element<'a, Message> {
//TODO: port to libcosmic
let menu_root = |label| {
@ -185,7 +221,13 @@ pub fn menu_bar<'a>(config: &Config, key_binds: &HashMap<KeyBind, Action>) -> El
menu_item(fl!("split-vertical"), Action::PaneSplitVertical),
menu_item(fl!("pane-toggle-maximize"), Action::PaneToggleMaximized),
MenuTree::new(horizontal_rule(1)),
menu_item(
fl!("menu-color-schemes"),
Action::ColorSchemes(config.color_scheme_kind()),
),
menu_item(fl!("menu-settings"), Action::Settings),
MenuTree::new(horizontal_rule(1)),
menu_item(fl!("menu-about"), Action::About),
],
),
])

View file

@ -39,7 +39,7 @@ use tokio::sync::mpsc;
pub use alacritty_terminal::grid::Scroll as TerminalScroll;
use crate::{
config::{Config as AppConfig, ProfileId},
config::{ColorSchemeKind, Config as AppConfig, ProfileId},
mouse_reporter::MouseReporter,
};
@ -505,10 +505,14 @@ impl Terminal {
let mut term = self.term.lock();
let grid = term.grid();
let start = Point::new(Line(-(grid.history_size() as i32)), Column(0));
let end = Point::new(
Line(grid.screen_lines() as i32 - 1),
Column(grid.columns() - 1),
);
let mut end_line = grid.bottommost_line();
while end_line.0 > 0 {
if !grid[end_line].is_clear() {
break;
}
end_line.0 -= 1;
}
let end = Point::new(end_line, Column(grid.columns() - 1));
let mut selection = Selection::new(SelectionType::Lines, start, Side::Left);
selection.update(end, Side::Right);
term.selection = Some(selection);
@ -519,7 +523,7 @@ impl Terminal {
pub fn set_config(
&mut self,
config: &AppConfig,
themes: &HashMap<String, Colors>,
themes: &HashMap<(String, ColorSchemeKind), Colors>,
zoom_adj: i8,
) {
let mut update_cell_size = false;
@ -559,7 +563,7 @@ impl Terminal {
update_cell_size = true;
}
if let Some(colors) = themes.get(config.syntax_theme(self.profile_id_opt)) {
if let Some(colors) = themes.get(&config.syntax_theme(self.profile_id_opt)) {
let mut changed = false;
for i in 0..color::COUNT {
if self.colors[i] != colors[i] {

View file

@ -2,11 +2,14 @@ use alacritty_terminal::{
term::color::Colors,
vte::ansi::{NamedColor, Rgb},
};
use hex_color::HexColor;
use palette::{encoding::Srgb, rgb::Rgb as PRgb, FromColor, Okhsl};
use std::collections::HashMap;
use std::{collections::HashMap, fs};
use crate::config::{ColorScheme, ColorSchemeAnsi, ColorSchemeKind};
// Fill missing dim/bright colors with derived values from normal ones.
#[allow(dead_code)]
struct ColorDerive {
dim_saturation_adjustment: f32,
dim_lightness_adjustment: f32,
@ -14,6 +17,7 @@ struct ColorDerive {
bright_lightness_adjustment: f32,
}
#[allow(dead_code)]
impl ColorDerive {
fn new() -> Self {
Self {
@ -138,311 +142,108 @@ fn auto_colors() -> Colors {
colors
}
fn tango_palette() -> Colors {
let mut colors = auto_colors();
impl From<&ColorScheme> for Colors {
fn from(color_scheme: &ColorScheme) -> Self {
let mut colors = auto_colors();
let encode_rgb = |data: u32| -> Rgb {
Rgb {
r: (data >> 16) as u8,
g: (data >> 8) as u8,
b: data as u8,
let encode_rgb = |rgb_opt: Option<HexColor>| -> Option<Rgb> {
let rgb = rgb_opt?;
Some(Rgb {
r: rgb.r,
g: rgb.g,
b: rgb.b,
})
};
// Set normal colors
colors[NamedColor::Black] = encode_rgb(color_scheme.normal.black);
colors[NamedColor::Red] = encode_rgb(color_scheme.normal.red);
colors[NamedColor::Green] = encode_rgb(color_scheme.normal.green);
colors[NamedColor::Yellow] = encode_rgb(color_scheme.normal.yellow);
colors[NamedColor::Blue] = encode_rgb(color_scheme.normal.blue);
colors[NamedColor::Magenta] = encode_rgb(color_scheme.normal.magenta);
colors[NamedColor::Cyan] = encode_rgb(color_scheme.normal.cyan);
colors[NamedColor::White] = encode_rgb(color_scheme.normal.white);
// Set bright colors
colors[NamedColor::BrightBlack] = encode_rgb(color_scheme.bright.black);
colors[NamedColor::BrightRed] = encode_rgb(color_scheme.bright.red);
colors[NamedColor::BrightGreen] = encode_rgb(color_scheme.bright.green);
colors[NamedColor::BrightYellow] = encode_rgb(color_scheme.bright.yellow);
colors[NamedColor::BrightBlue] = encode_rgb(color_scheme.bright.blue);
colors[NamedColor::BrightMagenta] = encode_rgb(color_scheme.bright.magenta);
colors[NamedColor::BrightCyan] = encode_rgb(color_scheme.bright.cyan);
colors[NamedColor::BrightWhite] = encode_rgb(color_scheme.bright.white);
// Set dim colors
colors[NamedColor::DimBlack] = encode_rgb(color_scheme.dim.black);
colors[NamedColor::DimRed] = encode_rgb(color_scheme.dim.red);
colors[NamedColor::DimGreen] = encode_rgb(color_scheme.dim.green);
colors[NamedColor::DimYellow] = encode_rgb(color_scheme.dim.yellow);
colors[NamedColor::DimBlue] = encode_rgb(color_scheme.dim.blue);
colors[NamedColor::DimMagenta] = encode_rgb(color_scheme.dim.magenta);
colors[NamedColor::DimCyan] = encode_rgb(color_scheme.dim.cyan);
colors[NamedColor::DimWhite] = encode_rgb(color_scheme.dim.white);
// Set special colors
colors[NamedColor::Foreground] = encode_rgb(color_scheme.foreground);
colors[NamedColor::Background] = encode_rgb(color_scheme.background);
colors[NamedColor::Cursor] = encode_rgb(color_scheme.cursor);
colors[NamedColor::BrightForeground] = encode_rgb(color_scheme.bright_foreground);
colors[NamedColor::DimForeground] = encode_rgb(color_scheme.dim_foreground);
colors
}
}
impl From<(&str, &Colors)> for ColorScheme {
fn from(tuple: (&str, &Colors)) -> Self {
let (name, colors) = tuple;
let encode_rgb = |rgb_opt: Option<Rgb>| -> Option<HexColor> {
let rgb = rgb_opt?;
Some(HexColor::rgb(rgb.r, rgb.g, rgb.b))
};
Self {
name: name.to_string(),
foreground: encode_rgb(colors[NamedColor::Foreground]),
background: encode_rgb(colors[NamedColor::Background]),
cursor: encode_rgb(colors[NamedColor::Cursor]),
bright_foreground: encode_rgb(colors[NamedColor::BrightForeground]),
dim_foreground: encode_rgb(colors[NamedColor::DimForeground]),
normal: ColorSchemeAnsi {
black: encode_rgb(colors[NamedColor::Black]),
red: encode_rgb(colors[NamedColor::Red]),
green: encode_rgb(colors[NamedColor::Green]),
yellow: encode_rgb(colors[NamedColor::Yellow]),
blue: encode_rgb(colors[NamedColor::Blue]),
magenta: encode_rgb(colors[NamedColor::Magenta]),
cyan: encode_rgb(colors[NamedColor::Cyan]),
white: encode_rgb(colors[NamedColor::White]),
},
bright: ColorSchemeAnsi {
black: encode_rgb(colors[NamedColor::BrightBlack]),
red: encode_rgb(colors[NamedColor::BrightRed]),
green: encode_rgb(colors[NamedColor::BrightGreen]),
yellow: encode_rgb(colors[NamedColor::BrightYellow]),
blue: encode_rgb(colors[NamedColor::BrightBlue]),
magenta: encode_rgb(colors[NamedColor::BrightMagenta]),
cyan: encode_rgb(colors[NamedColor::BrightCyan]),
white: encode_rgb(colors[NamedColor::BrightWhite]),
},
dim: ColorSchemeAnsi {
black: encode_rgb(colors[NamedColor::DimBlack]),
red: encode_rgb(colors[NamedColor::DimRed]),
green: encode_rgb(colors[NamedColor::DimGreen]),
yellow: encode_rgb(colors[NamedColor::DimYellow]),
blue: encode_rgb(colors[NamedColor::DimBlue]),
magenta: encode_rgb(colors[NamedColor::DimMagenta]),
cyan: encode_rgb(colors[NamedColor::DimCyan]),
white: encode_rgb(colors[NamedColor::DimWhite]),
},
}
};
colors[NamedColor::Black] = Some(encode_rgb(0x2E3436));
colors[NamedColor::Red] = Some(encode_rgb(0xCC0000));
colors[NamedColor::Green] = Some(encode_rgb(0x4E9A06));
colors[NamedColor::Yellow] = Some(encode_rgb(0xC4A000));
colors[NamedColor::Blue] = Some(encode_rgb(0x3465A4));
colors[NamedColor::Magenta] = Some(encode_rgb(0x75507B));
colors[NamedColor::Cyan] = Some(encode_rgb(0x06989A));
colors[NamedColor::White] = Some(encode_rgb(0xD3D7CF));
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x555753));
colors[NamedColor::BrightRed] = Some(encode_rgb(0xEF2929));
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x8AE234));
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xFCE94F));
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x729FCF));
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xAD7FA8));
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x34E2E2));
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xEEEEEC));
colors
}
fn tango_dark() -> Colors {
let mut colors = tango_palette();
// Set special colors
colors[NamedColor::Foreground] = colors[NamedColor::White];
colors[NamedColor::Background] = colors[NamedColor::Black];
colors[NamedColor::BrightForeground] = colors[NamedColor::BrightWhite];
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
// Fill missing dim colors
ColorDerive::new()
// Dim less so colors are readable with default bg
.with_dim_lightness_adjustment(-0.10)
.fill_missing_dims(&mut colors);
colors
}
fn tango_light() -> Colors {
let mut colors = tango_palette();
// Set special colors
colors[NamedColor::Foreground] = colors[NamedColor::Black];
colors[NamedColor::Background] = colors[NamedColor::BrightWhite];
colors[NamedColor::BrightForeground] = colors[NamedColor::BrightBlack];
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
// Fill missing dim colors
ColorDerive::new().fill_missing_dims(&mut colors);
colors
}
fn linux_console_palette() -> Colors {
let mut colors = auto_colors();
let encode_rgb = |data: u32| -> Rgb {
Rgb {
r: (data >> 16) as u8,
g: (data >> 8) as u8,
b: data as u8,
}
};
colors[NamedColor::Black] = Some(encode_rgb(0x000000));
colors[NamedColor::Red] = Some(encode_rgb(0xAA0000));
colors[NamedColor::Green] = Some(encode_rgb(0x00AA00));
colors[NamedColor::Yellow] = Some(encode_rgb(0xAA5500));
colors[NamedColor::Blue] = Some(encode_rgb(0x0000AA));
colors[NamedColor::Magenta] = Some(encode_rgb(0xAA00AA));
colors[NamedColor::Cyan] = Some(encode_rgb(0x00AAAA));
colors[NamedColor::White] = Some(encode_rgb(0xAAAAAA));
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x555555));
colors[NamedColor::BrightRed] = Some(encode_rgb(0xFF5555));
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x55FF55));
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xFFFF55));
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x5555FF));
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xFF55FF));
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x55FFFF));
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xFFFFFF));
colors
}
fn linux_console() -> Colors {
let mut colors = linux_console_palette();
// Set special colors
colors[NamedColor::Foreground] = colors[NamedColor::BrightWhite];
colors[NamedColor::Background] = colors[NamedColor::Black];
colors[NamedColor::BrightForeground] = colors[NamedColor::White];
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
// Fill missing dim colors
ColorDerive::new()
// Dim less so colors are readable with default bg
.with_dim_lightness_adjustment(-0.10)
.fill_missing_dims(&mut colors);
colors
}
fn xterm_palette() -> Colors {
let mut colors = auto_colors();
let encode_rgb = |data: u32| -> Rgb {
Rgb {
r: (data >> 16) as u8,
g: (data >> 8) as u8,
b: data as u8,
}
};
colors[NamedColor::Black] = Some(encode_rgb(0x000000));
colors[NamedColor::Red] = Some(encode_rgb(0xCD0000));
colors[NamedColor::Green] = Some(encode_rgb(0x00CD00));
colors[NamedColor::Yellow] = Some(encode_rgb(0xCDCD00));
colors[NamedColor::Blue] = Some(encode_rgb(0x0000EE));
colors[NamedColor::Magenta] = Some(encode_rgb(0xCD00CD));
colors[NamedColor::Cyan] = Some(encode_rgb(0x00CDCD));
colors[NamedColor::White] = Some(encode_rgb(0xE5E5E5));
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x7F7F7F));
colors[NamedColor::BrightRed] = Some(encode_rgb(0xFF0000));
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x00FF00));
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xFFFF00));
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x5C5CFF));
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xFF00FF));
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x00FFFF));
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xFFFFFF));
colors
}
fn xterm_dark() -> Colors {
let mut colors = xterm_palette();
// Set special colors
colors[NamedColor::Foreground] = colors[NamedColor::BrightWhite];
colors[NamedColor::Background] = colors[NamedColor::Black];
colors[NamedColor::BrightForeground] = colors[NamedColor::White];
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
// Fill missing dim colors
ColorDerive::new()
// Dim less so colors are readable with default bg
.with_dim_lightness_adjustment(-0.12)
.fill_missing_dims(&mut colors);
colors
}
fn xterm_light() -> Colors {
let mut colors = xterm_palette();
// Set special colors
colors[NamedColor::Foreground] = colors[NamedColor::Black];
colors[NamedColor::Background] = colors[NamedColor::BrightWhite];
colors[NamedColor::BrightForeground] = colors[NamedColor::BrightBlack];
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
// Fill missing dim colors
ColorDerive::new().fill_missing_dims(&mut colors);
colors
}
fn rxvt_palette() -> Colors {
let mut colors = auto_colors();
let encode_rgb = |data: u32| -> Rgb {
Rgb {
r: (data >> 16) as u8,
g: (data >> 8) as u8,
b: data as u8,
}
};
colors[NamedColor::Black] = Some(encode_rgb(0x000000));
colors[NamedColor::Red] = Some(encode_rgb(0xCD0000));
colors[NamedColor::Green] = Some(encode_rgb(0x00CD00));
colors[NamedColor::Yellow] = Some(encode_rgb(0xCDCD00));
colors[NamedColor::Blue] = Some(encode_rgb(0x0000CD));
colors[NamedColor::Magenta] = Some(encode_rgb(0xCD00CD));
colors[NamedColor::Cyan] = Some(encode_rgb(0x00CDCD));
colors[NamedColor::White] = Some(encode_rgb(0xFAEBD7));
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x404040));
colors[NamedColor::BrightRed] = Some(encode_rgb(0xFF0000));
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x00FF00));
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xFFFF00));
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x0000FF));
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xFF00FF));
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x00FFFF));
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xFFFFFF));
colors
}
fn rxvt_dark() -> Colors {
let mut colors = rxvt_palette();
// Set special colors
colors[NamedColor::Foreground] = colors[NamedColor::BrightWhite];
colors[NamedColor::Background] = colors[NamedColor::Black];
colors[NamedColor::BrightForeground] = colors[NamedColor::White];
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
// Fill missing dim colors
ColorDerive::new()
// Dim less so colors are readable with default bg
.with_dim_lightness_adjustment(-0.12)
.fill_missing_dims(&mut colors);
colors
}
fn rxvt_light() -> Colors {
let mut colors = rxvt_palette();
// Set special colors
colors[NamedColor::Foreground] = colors[NamedColor::Black];
colors[NamedColor::Background] = colors[NamedColor::BrightWhite];
colors[NamedColor::BrightForeground] = colors[NamedColor::BrightBlack];
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
// Fill missing dim colors
ColorDerive::new().fill_missing_dims(&mut colors);
colors
}
fn solarized_palette() -> Colors {
let mut colors = auto_colors();
let encode_rgb = |data: u32| -> Rgb {
Rgb {
r: (data >> 16) as u8,
g: (data >> 8) as u8,
b: data as u8,
}
};
colors[NamedColor::Black] = Some(encode_rgb(0x073642));
colors[NamedColor::Red] = Some(encode_rgb(0xDC322F));
colors[NamedColor::Green] = Some(encode_rgb(0x859900));
colors[NamedColor::Yellow] = Some(encode_rgb(0xB58900));
colors[NamedColor::Blue] = Some(encode_rgb(0x268BD2));
colors[NamedColor::Magenta] = Some(encode_rgb(0xD33682));
colors[NamedColor::Cyan] = Some(encode_rgb(0x2AA198));
colors[NamedColor::White] = Some(encode_rgb(0xEEE8D5));
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x002B36));
colors[NamedColor::BrightRed] = Some(encode_rgb(0xCB4B16));
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x586E75));
colors[NamedColor::BrightYellow] = Some(encode_rgb(0x657B83));
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x839496));
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0x6C71C4));
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x93A1A1));
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xFDF6E3));
colors
}
fn solarized_dark() -> Colors {
let mut colors = solarized_palette();
// Set special colors
colors[NamedColor::Foreground] = colors[NamedColor::BrightBlue];
colors[NamedColor::Background] = colors[NamedColor::BrightBlack];
colors[NamedColor::BrightForeground] = colors[NamedColor::Blue];
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
// Fill missing dim colors
ColorDerive::new().fill_missing_dims(&mut colors);
colors
}
fn solarized_light() -> Colors {
let mut colors = solarized_palette();
// Set special colors
colors[NamedColor::Foreground] = colors[NamedColor::BrightYellow];
colors[NamedColor::Background] = colors[NamedColor::BrightWhite];
colors[NamedColor::BrightForeground] = colors[NamedColor::Yellow];
colors[NamedColor::Cursor] = colors[NamedColor::Foreground];
// Fill missing dim colors
ColorDerive::new().fill_missing_dims(&mut colors);
colors
}
}
fn cosmic_dark() -> Colors {
@ -533,308 +334,50 @@ fn cosmic_light() -> Colors {
colors
}
fn gruvbox_dark() -> Colors {
let mut colors = auto_colors();
let encode_rgb = |data: u32| -> Rgb {
Rgb {
r: (data >> 16) as u8,
g: (data >> 8) as u8,
b: data as u8,
}
};
colors[NamedColor::Black] = Some(encode_rgb(0x282828));
colors[NamedColor::Red] = Some(encode_rgb(0xcc241d));
colors[NamedColor::Green] = Some(encode_rgb(0x98971a));
colors[NamedColor::Yellow] = Some(encode_rgb(0xd79921));
colors[NamedColor::Blue] = Some(encode_rgb(0x458588));
colors[NamedColor::Magenta] = Some(encode_rgb(0xb16286));
colors[NamedColor::Cyan] = Some(encode_rgb(0x689d6a));
colors[NamedColor::White] = Some(encode_rgb(0xa89984));
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x928374));
colors[NamedColor::BrightRed] = Some(encode_rgb(0xfb4934));
colors[NamedColor::BrightGreen] = Some(encode_rgb(0xb8bb26));
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xfabd2f));
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x83a598));
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xd3869b));
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x8ec07c));
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xebdbb2));
// Set special colors
colors[NamedColor::Foreground] = colors[NamedColor::BrightWhite];
colors[NamedColor::Background] = colors[NamedColor::Black];
colors[NamedColor::Cursor] = colors[NamedColor::BrightWhite];
colors[NamedColor::BrightForeground] = colors[NamedColor::BrightWhite];
// Fill missing dim colors
ColorDerive::new()
// Dim less so colors are readable with default bg
.with_dim_lightness_adjustment(-0.15)
.fill_missing_dims(&mut colors);
colors
}
fn one_half_dark() -> Colors {
let mut colors = auto_colors();
let encode_rgb = |data: u32| -> Rgb {
Rgb {
r: (data >> 16) as u8,
g: (data >> 8) as u8,
b: data as u8,
}
};
colors[NamedColor::Black] = Some(encode_rgb(0x282c34));
colors[NamedColor::Red] = Some(encode_rgb(0xe06c75));
colors[NamedColor::Green] = Some(encode_rgb(0x98c379));
colors[NamedColor::Yellow] = Some(encode_rgb(0xe5c07b));
colors[NamedColor::Blue] = Some(encode_rgb(0x61afef));
colors[NamedColor::Magenta] = Some(encode_rgb(0xc678dd));
colors[NamedColor::Cyan] = Some(encode_rgb(0x56b6c2));
colors[NamedColor::White] = Some(encode_rgb(0xdcdfe4));
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x5d677a));
// Set this before filling bright colors (including BrightForeground)
colors[NamedColor::Foreground] = colors[NamedColor::White];
let color_derive = ColorDerive::new();
// Fill missing bright colors
color_derive.fill_missing_brights(&mut colors);
// Set the rest of special colors
colors[NamedColor::Background] = colors[NamedColor::Black];
colors[NamedColor::Cursor] = colors[NamedColor::BrightWhite];
// Fill missing dim colors
color_derive.fill_missing_dims(&mut colors);
colors
}
fn pop_dark() -> Colors {
let mut colors = auto_colors();
let encode_rgb = |r: u8, g: u8, b: u8| -> Rgb { Rgb { r, g, b } };
// Pop colors (from pop-desktop gsettings)
colors[NamedColor::Black] = Some(encode_rgb(51, 51, 51));
colors[NamedColor::Red] = Some(encode_rgb(204, 0, 0));
colors[NamedColor::Green] = Some(encode_rgb(78, 154, 6));
colors[NamedColor::Yellow] = Some(encode_rgb(196, 160, 0));
colors[NamedColor::Blue] = Some(encode_rgb(52, 101, 164));
colors[NamedColor::Magenta] = Some(encode_rgb(117, 80, 123));
colors[NamedColor::Cyan] = Some(encode_rgb(6, 152, 154));
colors[NamedColor::White] = Some(encode_rgb(211, 215, 207));
colors[NamedColor::BrightBlack] = Some(encode_rgb(136, 128, 124));
colors[NamedColor::BrightRed] = Some(encode_rgb(241, 93, 34));
colors[NamedColor::BrightGreen] = Some(encode_rgb(115, 196, 143));
colors[NamedColor::BrightYellow] = Some(encode_rgb(255, 206, 81));
colors[NamedColor::BrightBlue] = Some(encode_rgb(72, 185, 199));
colors[NamedColor::BrightMagenta] = Some(encode_rgb(173, 127, 168));
colors[NamedColor::BrightCyan] = Some(encode_rgb(52, 226, 226));
colors[NamedColor::BrightWhite] = Some(encode_rgb(238, 238, 236));
// Set special colors
// Pop colors (from pop-desktop gsettings)
colors[NamedColor::Foreground] = Some(encode_rgb(242, 242, 242));
colors[NamedColor::Background] = Some(encode_rgb(51, 51, 51));
colors[NamedColor::Cursor] = colors[NamedColor::BrightWhite];
colors[NamedColor::BrightForeground] = colors[NamedColor::BrightWhite];
// Fill missing dim colors
ColorDerive::new()
// Dim less so colors are readable with default bg
.with_dim_lightness_adjustment(-0.05)
.fill_missing_dims(&mut colors);
colors
}
fn selenized_white() -> Colors {
let mut colors = auto_colors();
let encode_rgb = |data: u32| -> Rgb {
Rgb {
r: (data >> 16) as u8,
g: (data >> 8) as u8,
b: data as u8,
}
};
colors[NamedColor::Black] = Some(encode_rgb(0xEBEBEB));
colors[NamedColor::Red] = Some(encode_rgb(0xD6000C));
colors[NamedColor::Green] = Some(encode_rgb(0x1D9700));
colors[NamedColor::Yellow] = Some(encode_rgb(0xC49700));
colors[NamedColor::Blue] = Some(encode_rgb(0x0064E4));
colors[NamedColor::Magenta] = Some(encode_rgb(0xDD0F9D));
colors[NamedColor::Cyan] = Some(encode_rgb(0x00AD9C));
colors[NamedColor::White] = Some(encode_rgb(0x878787));
colors[NamedColor::BrightBlack] = Some(encode_rgb(0xCDCDCD));
colors[NamedColor::BrightRed] = Some(encode_rgb(0xBF0000));
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x008400));
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xAF8500));
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x0054CF));
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xC7008B));
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x009A8A));
colors[NamedColor::BrightWhite] = Some(encode_rgb(0x282828));
// Set special colors
colors[NamedColor::Background] = Some(encode_rgb(0xFFFFFF));
colors[NamedColor::Foreground] = Some(encode_rgb(0x474747));
colors[NamedColor::Cursor] = colors[NamedColor::Black];
// Fill missing dim colors
ColorDerive::new().fill_missing_dims(&mut colors);
colors
}
fn selenized_light() -> Colors {
let mut colors = auto_colors();
let encode_rgb = |data: u32| -> Rgb {
Rgb {
r: (data >> 16) as u8,
g: (data >> 8) as u8,
b: data as u8,
}
};
colors[NamedColor::Black] = Some(encode_rgb(0xECE3CC));
colors[NamedColor::Red] = Some(encode_rgb(0xD2212D));
colors[NamedColor::Green] = Some(encode_rgb(0x489100));
colors[NamedColor::Yellow] = Some(encode_rgb(0xAD8900));
colors[NamedColor::Blue] = Some(encode_rgb(0x0072D4));
colors[NamedColor::Magenta] = Some(encode_rgb(0xCA4898));
colors[NamedColor::Cyan] = Some(encode_rgb(0x009C8F));
colors[NamedColor::White] = Some(encode_rgb(0x909995));
colors[NamedColor::BrightBlack] = Some(encode_rgb(0xD5CDB6));
colors[NamedColor::BrightRed] = Some(encode_rgb(0xCC1729));
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x428B00));
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xA78300));
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x006DCE));
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xC44392));
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x00978A));
colors[NamedColor::BrightWhite] = Some(encode_rgb(0x3A4D53));
// Set special colors
colors[NamedColor::Background] = Some(encode_rgb(0xFBF3DB));
colors[NamedColor::Foreground] = Some(encode_rgb(0x53676D));
colors[NamedColor::Cursor] = colors[NamedColor::Black];
// Fill missing dim colors
ColorDerive::new().fill_missing_dims(&mut colors);
colors
}
fn selenized_dark() -> Colors {
let mut colors = auto_colors();
let encode_rgb = |data: u32| -> Rgb {
Rgb {
r: (data >> 16) as u8,
g: (data >> 8) as u8,
b: data as u8,
}
};
colors[NamedColor::Black] = Some(encode_rgb(0x184956));
colors[NamedColor::Red] = Some(encode_rgb(0xFA5750));
colors[NamedColor::Green] = Some(encode_rgb(0x75B938));
colors[NamedColor::Yellow] = Some(encode_rgb(0xDBB32D));
colors[NamedColor::Blue] = Some(encode_rgb(0x4695F7));
colors[NamedColor::Magenta] = Some(encode_rgb(0xF275BE));
colors[NamedColor::Cyan] = Some(encode_rgb(0x41C7B9));
colors[NamedColor::White] = Some(encode_rgb(0x72898F));
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x2D5B69));
colors[NamedColor::BrightRed] = Some(encode_rgb(0xFF665C));
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x84C747));
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xEBC13D));
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x58A3FF));
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xFF84CD));
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x53D6C7));
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xCAD8D9));
// Set special colors
colors[NamedColor::Background] = Some(encode_rgb(0x103C48));
colors[NamedColor::Foreground] = Some(encode_rgb(0xADBCBC));
colors[NamedColor::Cursor] = colors[NamedColor::White];
// Fill missing dim colors
ColorDerive::new().fill_missing_dims(&mut colors);
colors
}
fn selenized_black() -> Colors {
let mut colors = auto_colors();
let encode_rgb = |data: u32| -> Rgb {
Rgb {
r: (data >> 16) as u8,
g: (data >> 8) as u8,
b: data as u8,
}
};
colors[NamedColor::Black] = Some(encode_rgb(0x252525));
colors[NamedColor::Red] = Some(encode_rgb(0xED4A46));
colors[NamedColor::Green] = Some(encode_rgb(0x70B433));
colors[NamedColor::Yellow] = Some(encode_rgb(0xDBB32D));
colors[NamedColor::Blue] = Some(encode_rgb(0x368AEB));
colors[NamedColor::Magenta] = Some(encode_rgb(0xEB6EB7));
colors[NamedColor::Cyan] = Some(encode_rgb(0x3FC5B7));
colors[NamedColor::White] = Some(encode_rgb(0x777777));
colors[NamedColor::BrightBlack] = Some(encode_rgb(0x3B3B3B));
colors[NamedColor::BrightRed] = Some(encode_rgb(0xFF5E56));
colors[NamedColor::BrightGreen] = Some(encode_rgb(0x83C746));
colors[NamedColor::BrightYellow] = Some(encode_rgb(0xEFC541));
colors[NamedColor::BrightBlue] = Some(encode_rgb(0x4F9CFE));
colors[NamedColor::BrightMagenta] = Some(encode_rgb(0xFF81CA));
colors[NamedColor::BrightCyan] = Some(encode_rgb(0x56D8C9));
colors[NamedColor::BrightWhite] = Some(encode_rgb(0xDEDEDE));
// Set special colors
colors[NamedColor::Background] = Some(encode_rgb(0x181818));
colors[NamedColor::Foreground] = Some(encode_rgb(0xB9B9B9));
colors[NamedColor::Cursor] = colors[NamedColor::White];
// Fill missing dim colors
ColorDerive::new().fill_missing_dims(&mut colors);
colors
}
pub fn terminal_themes() -> HashMap<String, Colors> {
// Get builtin themes
pub fn terminal_themes() -> HashMap<(String, ColorSchemeKind), Colors> {
let mut themes = HashMap::new();
themes.insert("Tango Dark".to_string(), tango_dark());
themes.insert("Tango Light".to_string(), tango_light());
themes.insert("XTerm Dark".to_string(), xterm_dark());
themes.insert("XTerm Light".to_string(), xterm_light());
themes.insert("Linux Console".to_string(), linux_console());
themes.insert("Rxvt Dark".to_string(), rxvt_dark());
themes.insert("Rxvt Light".to_string(), rxvt_light());
themes.insert("Solarized Dark".to_string(), solarized_dark());
themes.insert("Solarized Light".to_string(), solarized_light());
themes.insert("COSMIC Dark".to_string(), cosmic_dark());
themes.insert("COSMIC Light".to_string(), cosmic_light());
themes.insert("gruvbox-dark".to_string(), gruvbox_dark());
themes.insert("OneHalfDark".to_string(), one_half_dark());
themes.insert("Pop Dark".to_string(), pop_dark());
themes.insert("Selenized Black".to_string(), selenized_black());
themes.insert("Selenized Dark".to_string(), selenized_dark());
themes.insert("Selenized Light".to_string(), selenized_light());
themes.insert("Selenized White".to_string(), selenized_white());
themes.insert(
("COSMIC Dark".to_string(), ColorSchemeKind::Dark),
cosmic_dark(),
);
themes.insert(
("COSMIC Light".to_string(), ColorSchemeKind::Light),
cosmic_light(),
);
themes
}
// Helper function to export builtin themes to theme files
#[allow(dead_code)]
pub fn export() {
for ((name, _color_scheme_kind), theme) in terminal_themes() {
let color_scheme = ColorScheme::from((name.as_str(), &theme));
// Ensure conversion to and from ColorScheme matches original theme
{
let theme_conv = Colors::from(&color_scheme);
for i in 0..alacritty_terminal::term::color::COUNT {
assert_eq!(theme[i], theme_conv[i]);
}
}
let ron = match ron::ser::to_string_pretty(&color_scheme, ron::ser::PrettyConfig::new()) {
Ok(ok) => ok,
Err(err) => {
log::error!("failed to export {name:?}: {err}");
continue;
}
};
let path = format!("color-schemes/{name}.ron");
match fs::write(&path, ron) {
Ok(()) => {
log::info!("exported {path:?}");
}
Err(err) => {
log::error!("failed to esport {path:?}: {err}");
}
}
}
}