diff options
| author | Mark Grey <mark.asperia@gmail.com> | 2025-02-07 05:59:54 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-07 11:59:54 +0100 |
| commit | 26b99eac63869fb1209ecf39c4f9cdb21d0419ba (patch) | |
| tree | 4a12d05dc3eb55b651ea90888e56932b2fb3bd73 /zellij-utils/src | |
| parent | docs(issue-template): clarify requirements (diff) | |
| download | sl0ppij-26b99eac63869fb1209ecf39c4f9cdb21d0419ba.tar.gz sl0ppij-26b99eac63869fb1209ecf39c4f9cdb21d0419ba.tar.xz sl0ppij-26b99eac63869fb1209ecf39c4f9cdb21d0419ba.zip | |
feat(config): new theme definition spec (#3242)
* Implement initial structs from spec
* kdl configuration unmarshalling
* typo text styling
* remove is_selected toggle
* incorporate new status bar ui into theming
* improve test coverage of config behavior
* tab bar correction
* correct also compact bar
* remove spacing between table columns
* refactor table styling
* use text_unselected.emphasis_1 for keygroup sep
* fix tab bar more text
* repair field flattening for theme
* remove extra styling KDL node
* update tests
* updated selected text conversion
* padding for header bar
* minor corrections for existing themes
* background handling
* compact bar corrections
* properly handle opaque method to activate background
* update newer plugins to use styling struct
* correct omission of selected state
* fix: bold typeface for text elements
* fix: fg -> white for list_unselected conversion
* fix: emphasis and opacity handling for nested_list
* correct stylings in the session-manager
* fix emphases translation for table component
* correct emphasis for run instructions
* correct frame_highlight translation for old themes
* provide missing implementation of frame_highlight
* fencepost emphasis color names
* Set a pseudo-None for frame_unselected in old theme conversion
* correct alternating bg for simplified-ui
* update snapshots
* fix inner text padding and errorneous snapshots
* suppress warning about deprecated usage of palette
* remove unused import
* feat(plugins): API to change floating pane coordinates (#3958)
* basic functionality through the cli
* added to plugin api
* add display area and viewport size to TabInfo
* fix tests and add new one
* some cleanups
* refactor: extract pane_id parsing logic
* style(fmt): rustfmt
* docs(changelog): floating pane coordinate chagne API
* fix(tiled-panes): opening panes from the cli (#3963)
* feat(plugins): add `PastedText` Event (#3962)
* working with text paste
* handle utf8 conversion error
* feat(plugins): add PastedText Event
* docs(changelog): plugins pasted text event
* black for table opaque background
* properly apply opacity to table
* correct padding for explicit width ribbons
* feat(plugins): Allow opening panes near plugin (#3966)
* added command + terminal variants
* added editor variant
* style(fmt): rustfmt
* docs(changelog): plugin apis to open panes near plugin
* feat(plugins): send info about $EDITOR and $SHELL (#3971)
* feat(plugins): send info about $EDITOR and $SHELL
* fix(e2e): snapshot update
* docs(changelog): plugin editor and shell info
* fix(floating-panes): when changing coordinates, if a pane is not floating - make it floating (#3972)
* fix(panes): when changing floating pane coordinates, if the pane is not floating, float it
* style(fmt): rustfmt
* docs(changelog): floating pane coordinate fix
* fix(break-pane): strip logical position when inserting pane to new tab (#3973)
* docs(changelog): logical position fix
* Optional frame_unselected theme
* fixture with correct width to account for arrow padding
* update snapshot and rustfmt
---------
Co-authored-by: Aram Drevekenin <aram@poor.dev>
Diffstat (limited to 'zellij-utils/src')
14 files changed, 4117 insertions, 474 deletions
diff --git a/zellij-utils/src/data.rs b/zellij-utils/src/data.rs index 5952d72e..3e912da2 100644 --- a/zellij-utils/src/data.rs +++ b/zellij-utils/src/data.rs @@ -2,6 +2,7 @@ use crate::input::actions::Action; use crate::input::config::ConversionError; use crate::input::keybinds::Keybinds; use crate::input::layout::{RunPlugin, SplitSize}; +use crate::shared::colors as default_colors; use clap::ArgEnum; use serde::{Deserialize, Serialize}; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; @@ -22,20 +23,21 @@ pub type ClientId = u16; // TODO: merge with crate type? pub fn client_id_to_colors( client_id: ClientId, - colors: Palette, + colors: MultiplayerColors, ) -> Option<(PaletteColor, PaletteColor)> { // (primary color, secondary color) + let black = PaletteColor::EightBit(default_colors::BLACK); match client_id { - 1 => Some((colors.magenta, colors.black)), - 2 => Some((colors.blue, colors.black)), - 3 => Some((colors.purple, colors.black)), - 4 => Some((colors.yellow, colors.black)), - 5 => Some((colors.cyan, colors.black)), - 6 => Some((colors.gold, colors.black)), - 7 => Some((colors.red, colors.black)), - 8 => Some((colors.silver, colors.black)), - 9 => Some((colors.pink, colors.black)), - 10 => Some((colors.brown, colors.black)), + 1 => Some((colors.player_1, black)), + 2 => Some((colors.player_2, black)), + 3 => Some((colors.player_3, black)), + 4 => Some((colors.player_4, black)), + 5 => Some((colors.player_5, black)), + 6 => Some((colors.player_6, black)), + 7 => Some((colors.player_7, black)), + 8 => Some((colors.player_8, black)), + 9 => Some((colors.player_9, black)), + 10 => Some((colors.player_10, black)), _ => None, } } @@ -1133,11 +1135,349 @@ pub struct Palette { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Default, Serialize, Deserialize)] pub struct Style { - pub colors: Palette, + pub colors: Styling, pub rounded_corners: bool, pub hide_session_name: bool, } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)] +pub enum Coloration { + NoStyling, + Styled(StyleDeclaration), +} + +impl Coloration { + pub fn with_fallback(&self, fallback: StyleDeclaration) -> StyleDeclaration { + match &self { + Coloration::NoStyling => fallback, + Coloration::Styled(style) => *style, + } + } +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)] +pub struct Styling { + pub text_unselected: StyleDeclaration, + pub text_selected: StyleDeclaration, + pub ribbon_unselected: StyleDeclaration, + pub ribbon_selected: StyleDeclaration, + pub table_title: StyleDeclaration, + pub table_cell_unselected: StyleDeclaration, + pub table_cell_selected: StyleDeclaration, + pub list_unselected: StyleDeclaration, + pub list_selected: StyleDeclaration, + pub frame_unselected: Option<StyleDeclaration>, + pub frame_selected: StyleDeclaration, + pub frame_highlight: StyleDeclaration, + pub exit_code_success: StyleDeclaration, + pub exit_code_error: StyleDeclaration, + pub multiplayer_user_colors: MultiplayerColors, +} + +#[derive(Debug, Copy, Default, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)] +pub struct StyleDeclaration { + pub base: PaletteColor, + pub background: PaletteColor, + pub emphasis_0: PaletteColor, + pub emphasis_1: PaletteColor, + pub emphasis_2: PaletteColor, + pub emphasis_3: PaletteColor, +} + +#[derive(Debug, Copy, Default, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)] +pub struct MultiplayerColors { + pub player_1: PaletteColor, + pub player_2: PaletteColor, + pub player_3: PaletteColor, + pub player_4: PaletteColor, + pub player_5: PaletteColor, + pub player_6: PaletteColor, + pub player_7: PaletteColor, + pub player_8: PaletteColor, + pub player_9: PaletteColor, + pub player_10: PaletteColor, +} + +pub const DEFAULT_STYLES: Styling = Styling { + text_unselected: StyleDeclaration { + base: PaletteColor::EightBit(default_colors::BRIGHT_GRAY), + emphasis_0: PaletteColor::EightBit(default_colors::ORANGE), + emphasis_1: PaletteColor::EightBit(default_colors::CYAN), + emphasis_2: PaletteColor::EightBit(default_colors::GREEN), + emphasis_3: PaletteColor::EightBit(default_colors::MAGENTA), + background: PaletteColor::EightBit(default_colors::GRAY), + }, + text_selected: StyleDeclaration { + base: PaletteColor::EightBit(default_colors::BRIGHT_GRAY), + emphasis_0: PaletteColor::EightBit(default_colors::ORANGE), + emphasis_1: PaletteColor::EightBit(default_colors::CYAN), + emphasis_2: PaletteColor::EightBit(default_colors::GREEN), + emphasis_3: PaletteColor::EightBit(default_colors::MAGENTA), + background: PaletteColor::EightBit(default_colors::GRAY), + }, + ribbon_unselected: StyleDeclaration { + base: PaletteColor::EightBit(default_colors::BLACK), + emphasis_0: PaletteColor::EightBit(default_colors::RED), + emphasis_1: PaletteColor::EightBit(default_colors::WHITE), + emphasis_2: PaletteColor::EightBit(default_colors::BLUE), + emphasis_3: PaletteColor::EightBit(default_colors::MAGENTA), + background: PaletteColor::EightBit(default_colors::GRAY), + }, + ribbon_selected: StyleDeclaration { + base: PaletteColor::EightBit(default_colors::BLACK), + emphasis_0: PaletteColor::EightBit(default_colors::RED), + emphasis_1: PaletteColor::EightBit(default_colors::ORANGE), + emphasis_2: PaletteColor::EightBit(default_colors::MAGENTA), + emphasis_3: PaletteColor::EightBit(default_colors::BLUE), + background: PaletteColor::EightBit(default_colors::GREEN), + }, + exit_code_success: StyleDeclaration { + base: PaletteColor::EightBit(default_colors::GREEN), + emphasis_0: PaletteColor::EightBit(default_colors::CYAN), + emphasis_1: PaletteColor::EightBit(default_colors::BLACK), + emphasis_2: PaletteColor::EightBit(default_colors::MAGENTA), + emphasis_3: PaletteColor::EightBit(default_colors::BLUE), + background: PaletteColor::EightBit(default_colors::GRAY), + }, + exit_code_error: StyleDeclaration { + base: PaletteColor::EightBit(default_colors::RED), + emphasis_0: PaletteColor::EightBit(default_colors::YELLOW), + emphasis_1: PaletteColor::EightBit(default_colors::GOLD), + emphasis_2: PaletteColor::EightBit(default_colors::SILVER), + emphasis_3: PaletteColor::EightBit(default_colors::PURPLE), + background: PaletteColor::EightBit(default_colors::GRAY), + }, + frame_unselected: None, + frame_selected: StyleDeclaration { + base: PaletteColor::EightBit(default_colors::GREEN), + emphasis_0: PaletteColor::EightBit(default_colors::ORANGE), + emphasis_1: PaletteColor::EightBit(default_colors::CYAN), + emphasis_2: PaletteColor::EightBit(default_colors::MAGENTA), + emphasis_3: PaletteColor::EightBit(default_colors::BROWN), + background: PaletteColor::EightBit(default_colors::GRAY), + }, + frame_highlight: StyleDeclaration { + base: PaletteColor::EightBit(default_colors::ORANGE), + emphasis_0: PaletteColor::EightBit(default_colors::GREEN), + emphasis_1: PaletteColor::EightBit(default_colors::GREEN), + emphasis_2: PaletteColor::EightBit(default_colors::GREEN), + emphasis_3: PaletteColor::EightBit(default_colors::GREEN), + background: PaletteColor::EightBit(default_colors::GREEN), + }, + table_title: StyleDeclaration { + base: PaletteColor::EightBit(default_colors::GREEN), + emphasis_0: PaletteColor::EightBit(default_colors::ORANGE), + emphasis_1: PaletteColor::EightBit(default_colors::CYAN), + emphasis_2: PaletteColor::EightBit(default_colors::GREEN), + emphasis_3: PaletteColor::EightBit(default_colors::MAGENTA), + background: PaletteColor::EightBit(default_colors::GRAY), + }, + table_cell_unselected: StyleDeclaration { + base: PaletteColor::EightBit(default_colors::BRIGHT_GRAY), + emphasis_0: PaletteColor::EightBit(default_colors::ORANGE), + emphasis_1: PaletteColor::EightBit(default_colors::CYAN), + emphasis_2: PaletteColor::EightBit(default_colors::GREEN), + emphasis_3: PaletteColor::EightBit(default_colors::MAGENTA), + background: PaletteColor::EightBit(default_colors::GRAY), + }, + table_cell_selected: StyleDeclaration { + base: PaletteColor::EightBit(default_colors::GREEN), + emphasis_0: PaletteColor::EightBit(default_colors::ORANGE), + emphasis_1: PaletteColor::EightBit(default_colors::CYAN), + emphasis_2: PaletteColor::EightBit(default_colors::RED), + emphasis_3: PaletteColor::EightBit(default_colors::MAGENTA), + background: PaletteColor::EightBit(default_colors::GRAY), + }, + list_unselected: StyleDeclaration { + base: PaletteColor::EightBit(default_colors::BRIGHT_GRAY), + emphasis_0: PaletteColor::EightBit(default_colors::ORANGE), + emphasis_1: PaletteColor::EightBit(default_colors::CYAN), + emphasis_2: PaletteColor::EightBit(default_colors::GREEN), + emphasis_3: PaletteColor::EightBit(default_colors::MAGENTA), + background: PaletteColor::EightBit(default_colors::GRAY), + }, + list_selected: StyleDeclaration { + base: PaletteColor::EightBit(default_colors::GREEN), + emphasis_0: PaletteColor::EightBit(default_colors::ORANGE), + emphasis_1: PaletteColor::EightBit(default_colors::CYAN), + emphasis_2: PaletteColor::EightBit(default_colors::RED), + emphasis_3: PaletteColor::EightBit(default_colors::MAGENTA), + background: PaletteColor::EightBit(default_colors::GRAY), + }, + multiplayer_user_colors: MultiplayerColors { + player_1: PaletteColor::EightBit(default_colors::MAGENTA), + player_2: PaletteColor::EightBit(default_colors::BLUE), + player_3: PaletteColor::EightBit(default_colors::PURPLE), + player_4: PaletteColor::EightBit(default_colors::YELLOW), + player_5: PaletteColor::EightBit(default_colors::CYAN), + player_6: PaletteColor::EightBit(default_colors::GOLD), + player_7: PaletteColor::EightBit(default_colors::RED), + player_8: PaletteColor::EightBit(default_colors::SILVER), + player_9: PaletteColor::EightBit(default_colors::PINK), + player_10: PaletteColor::EightBit(default_colors::BROWN), + }, +}; + +impl Default for Styling { + fn default() -> Self { + DEFAULT_STYLES + } +} + +impl From<Styling> for Palette { + fn from(styling: Styling) -> Self { + Palette { + theme_hue: ThemeHue::Dark, + source: PaletteSource::Default, + fg: styling.ribbon_unselected.background, + bg: styling.text_unselected.background, + red: styling.exit_code_error.base, + green: styling.text_unselected.emphasis_2, + yellow: styling.exit_code_error.emphasis_0, + blue: styling.ribbon_unselected.emphasis_2, + magenta: styling.text_unselected.emphasis_3, + orange: styling.text_unselected.emphasis_0, + cyan: styling.text_unselected.emphasis_1, + black: styling.ribbon_unselected.base, + white: styling.ribbon_unselected.emphasis_1, + gray: styling.list_unselected.background, + purple: styling.multiplayer_user_colors.player_3, + gold: styling.multiplayer_user_colors.player_6, + silver: styling.multiplayer_user_colors.player_8, + pink: styling.multiplayer_user_colors.player_9, + brown: styling.multiplayer_user_colors.player_10, + } + } +} + +impl From<Palette> for Styling { + fn from(palette: Palette) -> Self { + let (fg, bg) = match palette.theme_hue { + ThemeHue::Light => (palette.black, palette.white), + ThemeHue::Dark => (palette.white, palette.black), + }; + Styling { + text_unselected: StyleDeclaration { + base: fg, + emphasis_0: palette.orange, + emphasis_1: palette.cyan, + emphasis_2: palette.green, + emphasis_3: palette.magenta, + background: bg, + }, + text_selected: StyleDeclaration { + base: fg, + emphasis_0: palette.orange, + emphasis_1: palette.cyan, + emphasis_2: palette.green, + emphasis_3: palette.magenta, + background: palette.bg, + }, + ribbon_unselected: StyleDeclaration { + base: palette.black, + emphasis_0: palette.red, + emphasis_1: palette.white, + emphasis_2: palette.blue, + emphasis_3: palette.magenta, + background: palette.fg, + }, + ribbon_selected: StyleDeclaration { + base: palette.black, + emphasis_0: palette.red, + emphasis_1: palette.orange, + emphasis_2: palette.magenta, + emphasis_3: palette.blue, + background: palette.green, + }, + exit_code_success: StyleDeclaration { + base: palette.green, + emphasis_0: palette.cyan, + emphasis_1: palette.black, + emphasis_2: palette.magenta, + emphasis_3: palette.blue, + background: Default::default(), + }, + exit_code_error: StyleDeclaration { + base: palette.red, + emphasis_0: palette.yellow, + emphasis_1: palette.gold, + emphasis_2: palette.silver, + emphasis_3: palette.purple, + background: Default::default(), + }, + frame_unselected: None, + frame_selected: StyleDeclaration { + base: palette.green, + emphasis_0: palette.orange, + emphasis_1: palette.cyan, + emphasis_2: palette.magenta, + emphasis_3: palette.brown, + background: Default::default(), + }, + frame_highlight: StyleDeclaration { + base: palette.orange, + emphasis_0: palette.orange, + emphasis_1: palette.orange, + emphasis_2: palette.orange, + emphasis_3: palette.orange, + background: Default::default(), + }, + table_title: StyleDeclaration { + base: palette.green, + emphasis_0: palette.orange, + emphasis_1: palette.cyan, + emphasis_2: palette.green, + emphasis_3: palette.magenta, + background: palette.gray, + }, + table_cell_unselected: StyleDeclaration { + base: fg, + emphasis_0: palette.orange, + emphasis_1: palette.cyan, + emphasis_2: palette.green, + emphasis_3: palette.magenta, + background: palette.black, + }, + table_cell_selected: StyleDeclaration { + base: fg, + emphasis_0: palette.orange, + emphasis_1: palette.cyan, + emphasis_2: palette.green, + emphasis_3: palette.magenta, + background: palette.bg, + }, + list_unselected: StyleDeclaration { + base: palette.white, + emphasis_0: palette.orange, + emphasis_1: palette.cyan, + emphasis_2: palette.green, + emphasis_3: palette.magenta, + background: palette.black, + }, + list_selected: StyleDeclaration { + base: palette.white, + emphasis_0: palette.orange, + emphasis_1: palette.cyan, + emphasis_2: palette.green, + emphasis_3: palette.magenta, + background: palette.bg, + }, + multiplayer_user_colors: MultiplayerColors { + player_1: palette.magenta, + player_2: palette.blue, + player_3: palette.purple, + player_4: palette.yellow, + player_5: palette.cyan, + player_6: palette.gold, + player_7: palette.red, + player_8: palette.silver, + player_9: palette.pink, + player_10: palette.brown, + }, + } + } +} + // FIXME: Poor devs hashtable since HashTable can't derive `Default`... pub type KeybindsVec = Vec<(InputMode, Vec<(KeyWithModifier, Vec<Action>)>)>; @@ -1173,8 +1513,8 @@ impl ModeInfo { pub fn update_default_mode(&mut self, new_default_mode: InputMode) { self.base_mode = Some(new_default_mode); } - pub fn update_theme(&mut self, theme: Palette) { - self.style.colors = theme; + pub fn update_theme(&mut self, theme: Styling) { + self.style.colors = theme.into(); } pub fn update_rounded_corners(&mut self, rounded_corners: bool) { self.style.rounded_corners = rounded_corners; diff --git a/zellij-utils/src/input/config.rs b/zellij-utils/src/input/config.rs index 8075ea0d..445d507a 100644 --- a/zellij-utils/src/input/config.rs +++ b/zellij-utils/src/input/config.rs @@ -1,4 +1,4 @@ -use crate::data::Palette; +use crate::data::Styling; use miette::{Diagnostic, LabeledSpan, NamedSource, SourceCode}; use serde::{Deserialize, Serialize}; use std::collections::HashSet; @@ -166,7 +166,7 @@ impl TryFrom<&CliArgs> for Config { } impl Config { - pub fn theme_config(&self, theme_name: Option<&String>) -> Option<Palette> { + pub fn theme_config(&self, theme_name: Option<&String>) -> Option<Styling> { match &theme_name { Some(theme_name) => self.themes.get_theme(theme_name).map(|theme| theme.palette), None => self.themes.get_theme("default").map(|theme| theme.palette), @@ -407,8 +407,8 @@ impl Config { #[cfg(test)] mod config_test { use super::*; - use crate::data::{InputMode, Palette, PaletteColor}; - use crate::input::layout::RunPlugin; + use crate::data::{InputMode, Palette, PaletteColor, PluginTag, StyleDeclaration, Styling}; + use crate::input::layout::{RunPlugin, RunPluginLocation}; use crate::input::options::{Clipboard, OnForceClose}; use crate::input::theme::{FrameConfig, Theme, Themes, UiConfig}; use std::collections::{BTreeMap, HashMap}; @@ -630,7 +630,8 @@ mod config_test { black: PaletteColor::Rgb((0, 0, 0)), white: PaletteColor::Rgb((255, 255, 255)), ..Default::default() - }, + } + .into(), sourced_from_external_file: false, }, ); @@ -688,7 +689,8 @@ mod config_test { black: PaletteColor::Rgb((0, 0, 0)), white: PaletteColor::Rgb((255, 255, 255)), ..Default::default() - }, + } + .into(), sourced_from_external_file: false, }, ); @@ -708,7 +710,8 @@ mod config_test { white: PaletteColor::Rgb((229, 233, 240)), orange: PaletteColor::Rgb((208, 135, 112)), ..Default::default() - }, + } + .into(), sourced_from_external_file: false, }, ); @@ -753,7 +756,8 @@ mod config_test { black: PaletteColor::EightBit(1), white: PaletteColor::EightBit(255), ..Default::default() - }, + } + .into(), sourced_from_external_file: false, }, ); @@ -762,6 +766,304 @@ mod config_test { } #[test] + fn can_define_style_for_theme_with_hex() { + let config_contents = r##" + themes { + named_theme { + text_unselected { + base "#DCD7BA" + emphasis_0 "#DCD7CD" + emphasis_1 "#DCD8DD" + emphasis_2 "#DCD899" + emphasis_3 "#ACD7CD" + background "#1F1F28" + } + text_selected { + base "#16161D" + emphasis_0 "#16161D" + emphasis_1 "#16161D" + emphasis_2 "#16161D" + emphasis_3 "#16161D" + background "#9CABCA" + } + ribbon_unselected { + base "#DCD7BA" + emphasis_0 "#7FB4CA" + emphasis_1 "#A3D4D5" + emphasis_2 "#7AA89F" + emphasis_3 "#DCD819" + background "#252535" + } + ribbon_selected { + base "#16161D" + emphasis_0 "#181820" + emphasis_1 "#1A1A22" + emphasis_2 "#2A2A37" + emphasis_3 "#363646" + background "#76946A" + } + table_title { + base "#DCD7BA" + emphasis_0 "#7FB4CA" + emphasis_1 "#A3D4D5" + emphasis_2 "#7AA89F" + emphasis_3 "#DCD819" + background "#252535" + } + table_cell_unselected { + base "#DCD7BA" + emphasis_0 "#DCD7CD" + emphasis_1 "#DCD8DD" + emphasis_2 "#DCD899" + emphasis_3 "#ACD7CD" + background "#1F1F28" + } + table_cell_selected { + base "#16161D" + emphasis_0 "#181820" + emphasis_1 "#1A1A22" + emphasis_2 "#2A2A37" + emphasis_3 "#363646" + background "#76946A" + } + list_unselected { + base "#DCD7BA" + emphasis_0 "#DCD7CD" + emphasis_1 "#DCD8DD" + emphasis_2 "#DCD899" + emphasis_3 "#ACD7CD" + background "#1F1F28" + } + list_selected { + base "#16161D" + emphasis_0 "#181820" + emphasis_1 "#1A1A22" + emphasis_2 "#2A2A37" + emphasis_3 "#363646" + background "#76946A" + } + frame_unselected { + base "#DCD8DD" + emphasis_0 "#7FB4CA" + emphasis_1 "#A3D4D5" + emphasis_2 "#7AA89F" + emphasis_3 "#DCD819" + } + frame_selected { + base "#76946A" + emphasis_0 "#C34043" + emphasis_1 "#C8C093" + emphasis_2 "#ACD7CD" + emphasis_3 "#DCD819" + } + exit_code_success { + base "#76946A" + emphasis_0 "#76946A" + emphasis_1 "#76946A" + emphasis_2 "#76946A" + emphasis_3 "#76946A" + } + exit_code_error { + base "#C34043" + emphasis_0 "#C34043" + emphasis_1 "#C34043" + emphasis_2 "#C34043" + emphasis_3 "#C34043" + } + } + } + "##; + + let config = Config::from_kdl(config_contents, None).unwrap(); + let mut expected_themes = HashMap::new(); + expected_themes.insert( + "named_theme".into(), + Theme { + sourced_from_external_file: false, + palette: Styling { + text_unselected: StyleDeclaration { + base: PaletteColor::Rgb((220, 215, 186)), + emphasis_0: PaletteColor::Rgb((220, 215, 205)), + emphasis_1: PaletteColor::Rgb((220, 216, 221)), + emphasis_2: PaletteColor::Rgb((220, 216, 153)), + emphasis_3: PaletteColor::Rgb((172, 215, 205)), + background: PaletteColor::Rgb((31, 31, 40)), + }, + text_selected: StyleDeclaration { + base: PaletteColor::Rgb((22, 22, 29)), + emphasis_0: PaletteColor::Rgb((22, 22, 29)), + emphasis_1: PaletteColor::Rgb((22, 22, 29)), + emphasis_2: PaletteColor::Rgb((22, 22, 29)), + emphasis_3: PaletteColor::Rgb((22, 22, 29)), + background: PaletteColor::Rgb((156, 171, 202)), + }, + ribbon_unselected: StyleDeclaration { + base: PaletteColor::Rgb((220, 215, 186)), + emphasis_0: PaletteColor::Rgb((127, 180, 202)), + emphasis_1: PaletteColor::Rgb((163, 212, 213)), + emphasis_2: PaletteColor::Rgb((122, 168, 159)), + emphasis_3: PaletteColor::Rgb((220, 216, 25)), + background: PaletteColor::Rgb((37, 37, 53)), + }, + ribbon_selected: StyleDeclaration { + base: PaletteColor::Rgb((22, 22, 29)), + emphasis_0: PaletteColor::Rgb((24, 24, 32)), + emphasis_1: PaletteColor::Rgb((26, 26, 34)), + emphasis_2: PaletteColor::Rgb((42, 42, 55)), + emphasis_3: PaletteColor::Rgb((54, 54, 70)), + background: PaletteColor::Rgb((118, 148, 106)), + }, + table_title: StyleDeclaration { + base: PaletteColor::Rgb((220, 215, 186)), + emphasis_0: PaletteColor::Rgb((127, 180, 202)), + emphasis_1: PaletteColor::Rgb((163, 212, 213)), + emphasis_2: PaletteColor::Rgb((122, 168, 159)), + emphasis_3: PaletteColor::Rgb((220, 216, 25)), + background: PaletteColor::Rgb((37, 37, 53)), + }, + table_cell_unselected: StyleDeclaration { + base: PaletteColor::Rgb((220, 215, 186)), + emphasis_0: PaletteColor::Rgb((220, 215, 205)), + emphasis_1: PaletteColor::Rgb((220, 216, 221)), + emphasis_2: PaletteColor::Rgb((220, 216, 153)), + emphasis_3: PaletteColor::Rgb((172, 215, 205)), + background: PaletteColor::Rgb((31, 31, 40)), + }, + table_cell_selected: StyleDeclaration { + base: PaletteColor::Rgb((22, 22, 29)), + emphasis_0: PaletteColor::Rgb((24, 24, 32)), + emphasis_1: PaletteColor::Rgb((26, 26, 34)), + emphasis_2: PaletteColor::Rgb((42, 42, 55)), + emphasis_3: PaletteColor::Rgb((54, 54, 70)), + background: PaletteColor::Rgb((118, 148, 106)), + }, + list_unselected: StyleDeclaration { + base: PaletteColor::Rgb((220, 215, 186)), + emphasis_0: PaletteColor::Rgb((220, 215, 205)), + emphasis_1: PaletteColor::Rgb((220, 216, 221)), + emphasis_2: PaletteColor::Rgb((220, 216, 153)), + emphasis_3: PaletteColor::Rgb((172, 215, 205)), + background: PaletteColor::Rgb((31, 31, 40)), + }, + list_selected: StyleDeclaration { + base: PaletteColor::Rgb((22, 22, 29)), + emphasis_0: PaletteColor::Rgb((24, 24, 32)), + emphasis_1: PaletteColor::Rgb((26, 26, 34)), + emphasis_2: PaletteColor::Rgb((42, 42, 55)), + emphasis_3: PaletteColor::Rgb((54, 54, 70)), + background: PaletteColor::Rgb((118, 148, 106)), + }, + frame_unselected: Some(StyleDeclaration { + base: PaletteColor::Rgb((220, 216, 221)), + emphasis_0: PaletteColor::Rgb((127, 180, 202)), + emphasis_1: PaletteColor::Rgb((163, 212, 213)), + emphasis_2: PaletteColor::Rgb((122, 168, 159)), + emphasis_3: PaletteColor::Rgb((220, 216, 25)), + ..Default::default() + }), + frame_selected: StyleDeclaration { + base: PaletteColor::Rgb((118, 148, 106)), + emphasis_0: PaletteColor::Rgb((195, 64, 67)), + emphasis_1: PaletteColor::Rgb((200, 192, 147)), + emphasis_2: PaletteColor::Rgb((172, 215, 205)), + emphasis_3: PaletteColor::Rgb((220, 216, 25)), + ..Default::default() + }, + exit_code_success: StyleDeclaration { + base: PaletteColor::Rgb((118, 148, 106)), + emphasis_0: PaletteColor::Rgb((118, 148, 106)), + emphasis_1: PaletteColor::Rgb((118, 148, 106)), + emphasis_2: PaletteColor::Rgb((118, 148, 106)), + emphasis_3: PaletteColor::Rgb((118, 148, 106)), + ..Default::default() + }, + exit_code_error: StyleDeclaration { + base: PaletteColor::Rgb((195, 64, 67)), + emphasis_0: PaletteColor::Rgb((195, 64, 67)), + emphasis_1: PaletteColor::Rgb((195, 64, 67)), + emphasis_2: PaletteColor::Rgb((195, 64, 67)), + emphasis_3: PaletteColor::Rgb((195, 64, 67)), + ..Default::default() + }, + ..Default::default() + }, + }, + ); + let expected_themes = Themes::from_data(expected_themes); + assert_eq!(config.themes, expected_themes, "Theme defined in config") + } + + #[test] + fn omitting_required_style_errors() { + let config_contents = r##" + themes { + named_theme { + text_unselected { + base "#DCD7BA" + emphasis_1 "#DCD8DD" + emphasis_2 "#DCD899" + emphasis_3 "#ACD7CD" + background "#1F1F28" + } + } + } + "##; + + let config = Config::from_kdl(config_contents, None); + assert!(config.is_err()); + if let Err(ConfigError::KdlError(KdlError { + error_message, + src: _, + offset: _, + len: _, + help_message: _, + })) = config + { + assert_eq!(error_message, "Missing theme color: emphasis_0") + } + } + + #[test] + fn partial_declaration_of_styles_defaults_omitted() { + let config_contents = r##" + themes { + named_theme { + text_unselected { + base "#DCD7BA" + emphasis_0 "#DCD7CD" + emphasis_1 "#DCD8DD" + emphasis_2 "#DCD899" + emphasis_3 "#ACD7CD" + background "#1F1F28" + } + } + } + "##; + + let config = Config::from_kdl(config_contents, None).unwrap(); + let mut expected_themes = HashMap::new(); + expected_themes.insert( + "named_theme".into(), + Theme { + sourced_from_external_file: false, + palette: Styling { + text_unselected: StyleDeclaration { + base: PaletteColor::Rgb((220, 215, 186)), + emphasis_0: PaletteColor::Rgb((220, 215, 205)), + emphasis_1: PaletteColor::Rgb((220, 216, 221)), + emphasis_2: PaletteColor::Rgb((220, 216, 153)), + emphasis_3: PaletteColor::Rgb((172, 215, 205)), + background: PaletteColor::Rgb((31, 31, 40)), + }, + ..Default::default() + }, + }, + ); + let expected_themes = Themes::from_data(expected_themes); + assert_eq!(config.themes, expected_themes, "Theme defined in config") + } + + #[test] fn can_define_plugin_configuration_in_configfile() { let config_contents = r#" plugins { diff --git a/zellij-utils/src/input/theme.rs b/zellij-utils/src/input/theme.rs index a7f212f0..b4fbc630 100644 --- a/zellij-utils/src/input/theme.rs +++ b/zellij-utils/src/input/theme.rs @@ -7,7 +7,7 @@ use std::{ fmt, }; -use crate::data::Palette; +use crate::data::Styling; #[derive(Debug, Default, Clone, Copy, PartialEq, Deserialize, Serialize)] pub struct UiConfig { @@ -74,9 +74,9 @@ impl Themes { #[derive(Debug, Clone, PartialEq, Deserialize, Serialize)] pub struct Theme { - #[serde(flatten)] - pub palette: Palette, pub sourced_from_external_file: bool, + #[serde(flatten)] + pub palette: Styling, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] diff --git a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__theme__theme_test__dracula_theme_from_file.snap b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__theme__theme_test__dracula_theme_from_file.snap index 957ddf04..7fa1a55d 100644 --- a/zellij-utils/src/input/unit/snapshots/zellij_utils__input__theme__theme_test__dracula_theme_from_file.snap +++ b/zellij-utils/src/input/unit/snapshots/zellij_utils__input__theme__theme_test__dracula_theme_from_file.snap @@ -1,109 +1,600 @@ --- source: zellij-utils/src/input/./unit/theme_test.rs -assertion_line: 15 expression: "format!(\"{:#?}\", theme)" --- { "dracula": Theme { - palette: Palette { - source: Default, - theme_hue: Dark, - fg: Rgb( - ( - 248, - 248, - 242, + sourced_from_external_file: true, + palette: Styling { + text_unselected: StyleDeclaration { + base: Rgb( + ( + 255, + 255, + 255, + ), + ), + background: Rgb( + ( + 0, + 0, + 0, + ), + ), + emphasis_0: Rgb( + ( + 255, + 184, + 108, + ), + ), + emphasis_1: Rgb( + ( + 139, + 233, + 253, + ), + ), + emphasis_2: Rgb( + ( + 80, + 250, + 123, + ), + ), + emphasis_3: Rgb( + ( + 255, + 121, + 198, + ), + ), + }, + text_selected: StyleDeclaration { + base: Rgb( + ( + 255, + 255, + 255, + ), + ), + background: Rgb( + ( + 40, + 42, + 54, + ), + ), + emphasis_0: Rgb( + ( + 255, + 184, + 108, + ), + ), + emphasis_1: Rgb( + ( + 139, + 233, + 253, + ), + ), + emphasis_2: Rgb( + ( + 80, + 250, + 123, + ), + ), + emphasis_3: Rgb( + ( + 255, + 121, + 198, + ), + ), + }, + ribbon_unselected: StyleDeclaration { + base: Rgb( + ( + 0, + 0, + 0, + ), + ), + background: Rgb( + ( + 248, + 248, + 242, + ), + ), + emphasis_0: Rgb( + ( + 255, + 85, + 85, + ), + ), + emphasis_1: Rgb( + ( + 255, + 255, + 255, + ), + ), + emphasis_2: Rgb( + ( + 98, + 114, + 164, + ), + ), + emphasis_3: Rgb( + ( + 255, + 121, + 198, + ), + ), + }, + ribbon_selected: StyleDeclaration { + base: Rgb( + ( + 0, + 0, + 0, + ), + ), + background: Rgb( + ( + 80, + 250, + 123, + ), + ), + emphasis_0: Rgb( + ( + 255, + 85, + 85, + ), + ), + emphasis_1: Rgb( + ( + 255, + 184, + 108, + ), + ), + emphasis_2: Rgb( + ( + 255, + 121, + 198, + ), + ), + emphasis_3: Rgb( + ( + 98, + 114, + 164, + ), + ), + }, + table_title: StyleDeclaration { + base: Rgb( + ( + 80, + 250, + 123, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 255, + 184, + 108, + ), + ), + emphasis_1: Rgb( + ( + 139, + 233, + 253, + ), + ), + emphasis_2: Rgb( + ( + 80, + 250, + 123, + ), + ), + emphasis_3: Rgb( + ( + 255, + 121, + 198, + ), + ), + }, + table_cell_unselected: StyleDeclaration { + base: Rgb( + ( + 255, + 255, + 255, + ), + ), + background: Rgb( + ( + 0, + 0, + 0, + ), + ), + emphasis_0: Rgb( + ( + 255, + 184, + 108, + ), + ), + emphasis_1: Rgb( + ( + 139, + 233, + 253, + ), + ), + emphasis_2: Rgb( + ( + 80, + 250, + 123, + ), + ), + emphasis_3: Rgb( + ( + 255, + 121, + 198, + ), + ), + }, + table_cell_selected: StyleDeclaration { + base: Rgb( + ( + 255, + 255, + 255, + ), + ), + background: Rgb( + ( + 40, + 42, + 54, + ), + ), + emphasis_0: Rgb( + ( + 255, + 184, + 108, + ), + ), + emphasis_1: Rgb( + ( + 139, + 233, + 253, + ), + ), + emphasis_2: Rgb( + ( + 80, + 250, + 123, + ), + ), + emphasis_3: Rgb( + ( + 255, + 121, + 198, + ), + ), + }, + list_unselected: StyleDeclaration { + base: Rgb( + ( + 255, + 255, + 255, + ), + ), + background: Rgb( + ( + 0, + 0, + 0, + ), ), - ), - bg: Rgb( - ( - 40, - 42, - 54, + emphasis_0: Rgb( + ( + 255, + 184, + 108, + ), ), - ), - black: Rgb( - ( + emphasis_1: Rgb( + ( + 139, + 233, + 253, + ), + ), + emphasis_2: Rgb( + ( + 80, + 250, + 123, + ), + ), + emphasis_3: Rgb( + ( + 255, + 121, + 198, + ), + ), + }, + list_selected: StyleDeclaration { + base: Rgb( + ( + 255, + 255, + 255, + ), + ), + background: Rgb( + ( + 40, + 42, + 54, + ), + ), + emphasis_0: Rgb( + ( + 255, + 184, + 108, + ), + ), + emphasis_1: Rgb( + ( + 139, + 233, + 253, + ), + ), + emphasis_2: Rgb( + ( + 80, + 250, + 123, + ), + ), + emphasis_3: Rgb( + ( + 255, + 121, + 198, + ), + ), + }, + frame_unselected: None, + frame_selected: StyleDeclaration { + base: Rgb( + ( + 80, + 250, + 123, + ), + ), + background: EightBit( 0, + ), + emphasis_0: Rgb( + ( + 255, + 184, + 108, + ), + ), + emphasis_1: Rgb( + ( + 139, + 233, + 253, + ), + ), + emphasis_2: Rgb( + ( + 255, + 121, + 198, + ), + ), + emphasis_3: EightBit( 0, + ), + }, + frame_highlight: StyleDeclaration { + base: Rgb( + ( + 255, + 184, + 108, + ), + ), + background: EightBit( 0, ), - ), - red: Rgb( - ( - 255, - 85, - 85, + emphasis_0: Rgb( + ( + 255, + 184, + 108, + ), + ), + emphasis_1: Rgb( + ( + 255, + 184, + 108, + ), ), - ), - green: Rgb( - ( - 80, - 250, - 123, + emphasis_2: Rgb( + ( + 255, + 184, + 108, + ), ), - ), - yellow: Rgb( - ( - 241, - 250, - 140, + emphasis_3: Rgb( + ( + 255, + 184, + 108, + ), ), - ), - blue: Rgb( - ( - 98, - 114, - 164, + }, + exit_code_success: StyleDeclaration { + base: Rgb( + ( + 80, + 250, + 123, + ), ), - ), - magenta: Rgb( - ( - 255, - 121, - 198, + background: EightBit( + 0, ), - ), - cyan: Rgb( - ( - 139, - 233, - 253, + emphasis_0: Rgb( + ( + 139, + 233, + 253, + ), ), - ), - white: Rgb( - ( - 255, - 255, - 255, + emphasis_1: Rgb( + ( + 0, + 0, + 0, + ), + ), + emphasis_2: Rgb( + ( + 255, + 121, + 198, + ), + ), + emphasis_3: Rgb( + ( + 98, + 114, + 164, + ), + ), + }, + exit_code_error: StyleDeclaration { + base: Rgb( + ( + 255, + 85, + 85, + ), + ), + background: EightBit( + 0, ), - ), - orange: Rgb( - ( - 255, - 184, - 108, + emphasis_0: Rgb( + ( + 241, + 250, + 140, + ), ), - ), - gray: EightBit( - 0, - ), - purple: EightBit( - 0, - ), - gold: EightBit( - 0, - ), - silver: EightBit( - 0, - ), - pink: EightBit( - 0, - ), - brown: EightBit( - 0, - ), + emphasis_1: EightBit( + 0, + ), + emphasis_2: EightBit( + 0, + ), + emphasis_3: EightBit( + 0, + ), + }, + multiplayer_user_colors: MultiplayerColors { + player_1: Rgb( + ( + 255, + 121, + 198, + ), + ), + player_2: Rgb( + ( + 98, + 114, + 164, + ), + ), + player_3: EightBit( + 0, + ), + player_4: Rgb( + ( + 241, + 250, + 140, + ), + ), + player_5: Rgb( + ( + 139, + 233, + 253, + ), + ), + player_6: EightBit( + 0, + ), + player_7: Rgb( + ( + 255, + 85, + 85, + ), + ), + player_8: EightBit( + 0, + ), + player_9: EightBit( + 0, + ), + player_10: EightBit( + 0, + ), + }, }, - sourced_from_external_file: true, }, } diff --git a/zellij-utils/src/kdl/mod.rs b/zellij-utils/src/kdl/mod.rs index c46c17e8..ad4c86db 100644 --- a/zellij-utils/src/kdl/mod.rs +++ b/zellij-utils/src/kdl/mod.rs @@ -1,7 +1,8 @@ mod kdl_layout_parser; use crate::data::{ - BareKey, Direction, FloatingPaneCoordinates, InputMode, KeyWithModifier, LayoutInfo, Palette, - PaletteColor, PaneInfo, PaneManifest, PermissionType, Resize, SessionInfo, TabInfo, + BareKey, Direction, FloatingPaneCoordinates, InputMode, KeyWithModifier, LayoutInfo, + MultiplayerColors, Palette, PaletteColor, PaneInfo, PaneManifest, PermissionType, Resize, + SessionInfo, StyleDeclaration, Styling, TabInfo, DEFAULT_STYLES, }; use crate::envs::EnvironmentVariables; use crate::home::{find_default_config_dir, get_layout_dir}; @@ -1241,6 +1242,41 @@ impl PaletteColor { } } +impl StyleDeclaration { + pub fn to_kdl(&self, declaration_name: &str) -> KdlNode { + let mut node = KdlNode::new(declaration_name); + let mut doc = KdlDocument::new(); + + doc.nodes_mut().push(self.base.to_kdl("base")); + doc.nodes_mut().push(self.background.to_kdl("background")); + doc.nodes_mut().push(self.emphasis_0.to_kdl("emphasis_0")); + doc.nodes_mut().push(self.emphasis_1.to_kdl("emphasis_1")); + doc.nodes_mut().push(self.emphasis_2.to_kdl("emphasis_2")); + doc.nodes_mut().push(self.emphasis_3.to_kdl("emphasis_3")); + node.set_children(doc); + node + } +} + +impl MultiplayerColors { + pub fn to_kdl(&self) -> KdlNode { + let mut node = KdlNode::new("multiplayer_user_colors"); + let mut doc = KdlDocument::new(); + doc.nodes_mut().push(self.player_1.to_kdl("player_1")); + doc.nodes_mut().push(self.player_2.to_kdl("player_2")); + doc.nodes_mut().push(self.player_3.to_kdl("player_3")); + doc.nodes_mut().push(self.player_4.to_kdl("player_4")); + doc.nodes_mut().push(self.player_5.to_kdl("player_5")); + doc.nodes_mut().push(self.player_6.to_kdl("player_6")); + doc.nodes_mut().push(self.player_7.to_kdl("player_7")); + doc.nodes_mut().push(self.player_8.to_kdl("player_8")); + doc.nodes_mut().push(self.player_9.to_kdl("player_9")); + doc.nodes_mut().push(self.player_10.to_kdl("player_10")); + node.set_children(doc); + node + } +} + impl TryFrom<(&KdlNode, &Options)> for Action { type Error = ConfigError; fn try_from((kdl_action, config_options): (&KdlNode, &Options)) -> Result<Self, Self::Error> { @@ -2052,6 +2088,20 @@ macro_rules! kdl_child_with_name { } #[macro_export] +macro_rules! kdl_child_with_name_or_error { + ( $kdl_node:expr, $name:expr) => {{ + $kdl_node + .children() + .and_then(|children| children.nodes().iter().find(|c| c.name().value() == $name)) + .ok_or(ConfigError::new_kdl_error( + format!("Missing node {}", $name).into(), + $kdl_node.span().offset(), + $kdl_node.span().len(), + )) + }}; +} + +#[macro_export] macro_rules! kdl_get_string_property_or_child_value_with_error { ( $kdl_node:expr, $name:expr ) => { match $kdl_node.get($name) { @@ -3930,6 +3980,66 @@ impl UiConfig { } impl Themes { + fn style_declaration_from_node( + style_node: &KdlNode, + style_descriptor: &str, + ) -> Result<Option<StyleDeclaration>, ConfigError> { + let descriptor_node = kdl_child_with_name!(style_node, style_descriptor); + + match descriptor_node { + Some(descriptor) => { + let colors = kdl_children_or_error!( + descriptor, + format!("Missing colors for {}", style_descriptor) + ); + Ok(Some(StyleDeclaration { + base: PaletteColor::try_from(("base", colors))?, + background: PaletteColor::try_from(("background", colors)).unwrap_or_default(), + emphasis_0: PaletteColor::try_from(("emphasis_0", colors))?, + emphasis_1: PaletteColor::try_from(("emphasis_1", colors))?, + emphasis_2: PaletteColor::try_from(("emphasis_2", colors))?, + emphasis_3: PaletteColor::try_from(("emphasis_3", colors))?, + })) + }, + None => Ok(None), + } + } + + fn multiplayer_colors(style_node: &KdlNode) -> Result<MultiplayerColors, ConfigError> { + let descriptor_node = kdl_child_with_name!(style_node, "multiplayer_user_colors"); + match descriptor_node { + Some(descriptor) => { + let colors = kdl_children_or_error!( + descriptor, + format!("Missing colors for {}", "multiplayer_user_colors") + ); + Ok(MultiplayerColors { + player_1: PaletteColor::try_from(("player_1", colors)) + .unwrap_or(DEFAULT_STYLES.multiplayer_user_colors.player_1), + player_2: PaletteColor::try_from(("player_2", colors)) + .unwrap_or(DEFAULT_STYLES.multiplayer_user_colors.player_2), + player_3: PaletteColor::try_from(("player_3", colors)) + .unwrap_or(DEFAULT_STYLES.multiplayer_user_colors.player_3), + player_4: PaletteColor::try_from(("player_4", colors)) + .unwrap_or(DEFAULT_STYLES.multiplayer_user_colors.player_4), + player_5: PaletteColor::try_from(("player_5", colors)) + .unwrap_or(DEFAULT_STYLES.multiplayer_user_colors.player_5), + player_6: PaletteColor::try_from(("player_6", colors)) + .unwrap_or(DEFAULT_STYLES.multiplayer_user_colors.player_6), + player_7: PaletteColor::try_from(("player_7", colors)) + .unwrap_or(DEFAULT_STYLES.multiplayer_user_colors.player_7), + player_8: PaletteColor::try_from(("player_8", colors)) + .unwrap_or(DEFAULT_STYLES.multiplayer_user_colors.player_8), + player_9: PaletteColor::try_from(("player_9", colors)) + .unwrap_or(DEFAULT_STYLES.multiplayer_user_colors.player_9), + player_10: PaletteColor::try_from(("player_10", colors)) + .unwrap_or(DEFAULT_STYLES.multiplayer_user_colors.player_10), + }) + }, + None => Ok(DEFAULT_STYLES.multiplayer_user_colors), + } + } + pub fn from_kdl( themes_from_kdl: &KdlNode, sourced_from_external_file: bool, @@ -3938,8 +4048,17 @@ impl Themes { for theme_config in kdl_children_nodes_or_error!(themes_from_kdl, "no themes found") { let theme_name = kdl_name!(theme_config); let theme_colors = kdl_children_or_error!(theme_config, "empty theme"); - let theme = Theme { - palette: Palette { + let palette_color_names = HashSet::from([ + "fg", "bg", "red", "green", "blue", "yellow", "magenta", "orange", "cyan", "black", + "white", + ]); + let theme = if theme_colors + .nodes() + .iter() + .all(|n| palette_color_names.contains(n.name().value())) + { + // Older palette based theme definition + let palette = Palette { fg: PaletteColor::try_from(("fg", theme_colors))?, bg: PaletteColor::try_from(("bg", theme_colors))?, red: PaletteColor::try_from(("red", theme_colors))?, @@ -3952,8 +4071,92 @@ impl Themes { black: PaletteColor::try_from(("black", theme_colors))?, white: PaletteColor::try_from(("white", theme_colors))?, ..Default::default() - }, - sourced_from_external_file, + }; + Theme { + palette: palette.into(), + sourced_from_external_file, + } + } else { + // Newer theme definition with named styles + let s = Styling { + text_unselected: Themes::style_declaration_from_node( + theme_config, + "text_unselected", + ) + .map(|maybe_style| maybe_style.unwrap_or(DEFAULT_STYLES.text_unselected))?, + text_selected: Themes::style_declaration_from_node( + theme_config, + "text_selected", + ) + .map(|maybe_style| maybe_style.unwrap_or(DEFAULT_STYLES.text_selected))?, + ribbon_unselected: Themes::style_declaration_from_node( + theme_config, + "ribbon_unselected", + ) + .map(|maybe_style| maybe_style.unwrap_or(DEFAULT_STYLES.ribbon_unselected))?, + ribbon_selected: Themes::style_declaration_from_node( + theme_config, + "ribbon_selected", + ) + .map(|maybe_style| maybe_style.unwrap_or(DEFAULT_STYLES.ribbon_selected))?, + table_title: Themes::style_declaration_from_node(theme_config, "table_title") + .map(|maybe_style| { + maybe_style.unwrap_or(DEFAULT_STYLES.table_title) + })?, + table_cell_unselected: Themes::style_declaration_from_node( + theme_config, + "table_cell_unselected", + ) + .map(|maybe_style| { + maybe_style.unwrap_or(DEFAULT_STYLES.table_cell_unselected) + })?, + table_cell_selected: Themes::style_declaration_from_node( + theme_config, + "table_cell_selected", + ) + .map(|maybe_style| maybe_style.unwrap_or(DEFAULT_STYLES.table_cell_selected))?, + list_unselected: Themes::style_declaration_from_node( + theme_config, + "list_unselected", + ) + .map(|maybe_style| maybe_style.unwrap_or(DEFAULT_STYLES.list_unselected))?, + list_selected: Themes::style_declaration_from_node( + theme_config, + "list_selected", + ) + .map(|maybe_style| maybe_style.unwrap_or(DEFAULT_STYLES.list_selected))?, + frame_unselected: Themes::style_declaration_from_node( + theme_config, + "frame_unselected", + )?, + frame_selected: Themes::style_declaration_from_node( + theme_config, + "frame_selected", + ) + .map(|maybe_style| maybe_style.unwrap_or(DEFAULT_STYLES.frame_selected))?, + frame_highlight: Themes::style_declaration_from_node( + theme_config, + "frame_highlight", + ) + .map(|maybe_style| maybe_style.unwrap_or(DEFAULT_STYLES.frame_highlight))?, + exit_code_success: Themes::style_declaration_from_node( + theme_config, + "exit_code_success", + ) + .map(|maybe_style| maybe_style.unwrap_or(DEFAULT_STYLES.exit_code_success))?, + exit_code_error: Themes::style_declaration_from_node( + theme_config, + "exit_code_error", + ) + .map(|maybe_style| maybe_style.unwrap_or(DEFAULT_STYLES.exit_code_error))?, + multiplayer_user_colors: Themes::multiplayer_colors(theme_config) + .unwrap_or_default(), + }; + + Theme { + palette: s, + sourced_from_external_file, + } }; themes.insert(theme_name.into(), theme); } @@ -4017,39 +4220,64 @@ impl Themes { has_themes = true; let mut current_theme_node = KdlNode::new(theme_name.clone()); let mut current_theme_node_children = KdlDocument::new(); + current_theme_node_children .nodes_mut() - .push(theme.palette.fg.to_kdl("fg")); + .push(theme.palette.text_unselected.to_kdl("text_unselected")); current_theme_node_children .nodes_mut() - .push(theme.palette.bg.to_kdl("bg")); + .push(theme.palette.text_selected.to_kdl("text_selected")); current_theme_node_children .nodes_mut() - .push(theme.palette.red.to_kdl("red")); + .push(theme.palette.ribbon_selected.to_kdl("ribbon_selected")); current_theme_node_children .nodes_mut() - .push(theme.palette.green.to_kdl("green")); + .push(theme.palette.ribbon_unselected.to_kdl("ribbon_unselected")); current_theme_node_children .nodes_mut() - .push(theme.palette.yellow.to_kdl("yellow")); + .push(theme.palette.table_title.to_kdl("table_title")); + current_theme_node_children.nodes_mut().push( + theme + .palette + .table_cell_selected + .to_kdl("table_cell_selected"), + ); + current_theme_node_children.nodes_mut().push( + theme + .palette + .table_cell_unselected + .to_kdl("table_cell_unselected"), + ); current_theme_node_children .nodes_mut() - .push(theme.palette.blue.to_kdl("blue")); + .push(theme.palette.list_selected.to_kdl("list_selected")); current_theme_node_children .nodes_mut() - .push(theme.palette.magenta.to_kdl("magenta")); + .push(theme.palette.list_unselected.to_kdl("list_unselected")); current_theme_node_children .nodes_mut() - .push(theme.palette.orange.to_kdl("orange")); + .push(theme.palette.frame_selected.to_kdl("frame_selected")); + + match theme.palette.frame_unselected { + None => {}, + Some(frame_unselected_style) => { + current_theme_node_children + .nodes_mut() + .push(frame_unselected_style.to_kdl("frame_unselected")); + }, + } current_theme_node_children .nodes_mut() - .push(theme.palette.cyan.to_kdl("cyan")); + .push(theme.palette.frame_highlight.to_kdl("frame_highlight")); current_theme_node_children .nodes_mut() - .push(theme.palette.black.to_kdl("black")); + .push(theme.palette.exit_code_success.to_kdl("exit_code_success")); current_theme_node_children .nodes_mut() - .push(theme.palette.white.to_kdl("white")); + .push(theme.palette.exit_code_error.to_kdl("exit_code_error")); + current_theme_node_children + .nodes_mut() + .push(theme.palette.multiplayer_user_colors.to_kdl()); current_theme_node.set_children(current_theme_node_children); themes.nodes_mut().push(current_theme_node); } @@ -5168,7 +5396,7 @@ fn themes_to_string() { .unwrap(); assert_eq!( deserialized, deserialized_from_serialized, - "Deserialized serialized config equals original config" + "Deserialized serialized config equals original config", ); insta::assert_snapshot!(serialized.to_string()); } diff --git a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string.snap b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string.snap index 7bbc19cd..f1381601 100644 --- a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string.snap +++ b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string.snap @@ -1,20 +1,124 @@ --- source: zellij-utils/src/kdl/mod.rs -assertion_line: 3697 expression: serialized.to_string() --- themes { dracula { - fg 248 248 242 - bg 40 42 54 - red 255 85 85 - green 80 250 123 - yellow 241 250 140 - blue 98 114 164 - magenta 255 121 198 - orange 255 184 108 - cyan 139 233 253 - black 0 0 0 - white 255 255 255 + text_unselected { + base 255 255 255 + background 0 0 0 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 80 250 123 + emphasis_3 255 121 198 + } + text_selected { + base 255 255 255 + background 40 42 54 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 80 250 123 + emphasis_3 255 121 198 + } + ribbon_selected { + base 0 0 0 + background 80 250 123 + emphasis_0 255 85 85 + emphasis_1 255 184 108 + emphasis_2 255 121 198 + emphasis_3 98 114 164 + } + ribbon_unselected { + base 0 0 0 + background 248 248 242 + emphasis_0 255 85 85 + emphasis_1 255 255 255 + emphasis_2 98 114 164 + emphasis_3 255 121 198 + } + table_title { + base 80 250 123 + background 0 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 80 250 123 + emphasis_3 255 121 198 + } + table_cell_selected { + base 255 255 255 + background 40 42 54 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 80 250 123 + emphasis_3 255 121 198 + } + table_cell_unselected { + base 255 255 255 + background 0 0 0 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 80 250 123 + emphasis_3 255 121 198 + } + list_selected { + base 255 255 255 + background 40 42 54 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 80 250 123 + emphasis_3 255 121 198 + } + list_unselected { + base 255 255 255 + background 0 0 0 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 80 250 123 + emphasis_3 255 121 198 + } + frame_selected { + base 80 250 123 + background 0 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 255 121 198 + emphasis_3 0 + } + frame_highlight { + base 255 184 108 + background 0 + emphasis_0 255 184 108 + emphasis_1 255 184 108 + emphasis_2 255 184 108 + emphasis_3 255 184 108 + } + exit_code_success { + base 80 250 123 + background 0 + emphasis_0 139 233 253 + emphasis_1 0 0 0 + emphasis_2 255 121 198 + emphasis_3 98 114 164 + } + exit_code_error { + base 255 85 85 + background 0 + emphasis_0 241 250 140 + emphasis_1 0 + emphasis_2 0 + emphasis_3 0 + } + multiplayer_user_colors { + player_1 255 121 198 + player_2 98 114 164 + player_3 0 + player_4 241 250 140 + player_5 139 233 253 + player_6 0 + player_7 255 85 85 + player_8 0 + player_9 0 + player_10 0 + } } } diff --git a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_combined_definitions.snap b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_combined_definitions.snap index 3498af78..ae92e207 100644 --- a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_combined_definitions.snap +++ b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_combined_definitions.snap @@ -1,20 +1,124 @@ --- source: zellij-utils/src/kdl/mod.rs -assertion_line: 3775 expression: serialized.to_string() --- themes { default { - fg 1 - bg 10 - red 30 - green 40 - yellow 50 - blue 60 - magenta 70 - orange 208 135 112 - cyan 80 - black 20 - white 255 255 255 + text_unselected { + base 255 255 255 + background 20 + emphasis_0 208 135 112 + emphasis_1 80 + emphasis_2 40 + emphasis_3 70 + } + text_selected { + base 255 255 255 + background 10 + emphasis_0 208 135 112 + emphasis_1 80 + emphasis_2 40 + emphasis_3 70 + } + ribbon_selected { + base 20 + background 40 + emphasis_0 30 + emphasis_1 208 135 112 + emphasis_2 70 + emphasis_3 60 + } + ribbon_unselected { + base 20 + background 1 + emphasis_0 30 + emphasis_1 255 255 255 + emphasis_2 60 + emphasis_3 70 + } + table_title { + base 40 + background 0 + emphasis_0 208 135 112 + emphasis_1 80 + emphasis_2 40 + emphasis_3 70 + } + table_cell_selected { + base 255 255 255 + background 10 + emphasis_0 208 135 112 + emphasis_1 80 + emphasis_2 40 + emphasis_3 70 + } + table_cell_unselected { + base 255 255 255 + background 20 + emphasis_0 208 135 112 + emphasis_1 80 + emphasis_2 40 + emphasis_3 70 + } + list_selected { + base 255 255 255 + background 10 + emphasis_0 208 135 112 + emphasis_1 80 + emphasis_2 40 + emphasis_3 70 + } + list_unselected { + base 255 255 255 + background 20 + emphasis_0 208 135 112 + emphasis_1 80 + emphasis_2 40 + emphasis_3 70 + } + frame_selected { + base 40 + background 0 + emphasis_0 208 135 112 + emphasis_1 80 + emphasis_2 70 + emphasis_3 0 + } + frame_highlight { + base 208 135 112 + background 0 + emphasis_0 208 135 112 + emphasis_1 208 135 112 + emphasis_2 208 135 112 + emphasis_3 208 135 112 + } + exit_code_success { + base 40 + background 0 + emphasis_0 80 + emphasis_1 20 + emphasis_2 70 + emphasis_3 60 + } + exit_code_error { + base 30 + background 0 + emphasis_0 50 + emphasis_1 0 + emphasis_2 0 + emphasis_3 0 + } + multiplayer_user_colors { + player_1 70 + player_2 60 + player_3 0 + player_4 50 + player_5 80 + player_6 0 + player_7 30 + player_8 0 + player_9 0 + player_10 0 + } } } diff --git a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_eight_bit_definitions.snap b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_eight_bit_definitions.snap index 5406cbb8..12696b9c 100644 --- a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_eight_bit_definitions.snap +++ b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_eight_bit_definitions.snap @@ -1,20 +1,124 @@ --- source: zellij-utils/src/kdl/mod.rs -assertion_line: 3749 expression: serialized.to_string() --- themes { default { - fg 1 - bg 10 - red 30 - green 40 - yellow 50 - blue 60 - magenta 70 - orange 254 - cyan 80 - black 20 - white 90 + text_unselected { + base 90 + background 20 + emphasis_0 254 + emphasis_1 80 + emphasis_2 40 + emphasis_3 70 + } + text_selected { + base 90 + background 10 + emphasis_0 254 + emphasis_1 80 + emphasis_2 40 + emphasis_3 70 + } + ribbon_selected { + base 20 + background 40 + emphasis_0 30 + emphasis_1 254 + emphasis_2 70 + emphasis_3 60 + } + ribbon_unselected { + base 20 + background 1 + emphasis_0 30 + emphasis_1 90 + emphasis_2 60 + emphasis_3 70 + } + table_title { + base 40 + background 0 + emphasis_0 254 + emphasis_1 80 + emphasis_2 40 + emphasis_3 70 + } + table_cell_selected { + base 90 + background 10 + emphasis_0 254 + emphasis_1 80 + emphasis_2 40 + emphasis_3 70 + } + table_cell_unselected { + base 90 + background 20 + emphasis_0 254 + emphasis_1 80 + emphasis_2 40 + emphasis_3 70 + } + list_selected { + base 90 + background 10 + emphasis_0 254 + emphasis_1 80 + emphasis_2 40 + emphasis_3 70 + } + list_unselected { + base 90 + background 20 + emphasis_0 254 + emphasis_1 80 + emphasis_2 40 + emphasis_3 70 + } + frame_selected { + base 40 + background 0 + emphasis_0 254 + emphasis_1 80 + emphasis_2 70 + emphasis_3 0 + } + frame_highlight { + base 254 + background 0 + emphasis_0 254 + emphasis_1 254 + emphasis_2 254 + emphasis_3 254 + } + exit_code_success { + base 40 + background 0 + emphasis_0 80 + emphasis_1 20 + emphasis_2 70 + emphasis_3 60 + } + exit_code_error { + base 30 + background 0 + emphasis_0 50 + emphasis_1 0 + emphasis_2 0 + emphasis_3 0 + } + multiplayer_user_colors { + player_1 70 + player_2 60 + player_3 0 + player_4 50 + player_5 80 + player_6 0 + player_7 30 + player_8 0 + player_9 0 + player_10 0 + } } } diff --git a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_hex_definitions.snap b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_hex_definitions.snap index 3cbf559a..81d041ac 100644 --- a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_hex_definitions.snap +++ b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_hex_definitions.snap @@ -1,20 +1,124 @@ --- source: zellij-utils/src/kdl/mod.rs -assertion_line: 3723 expression: serialized.to_string() --- themes { nord { - fg 216 222 233 - bg 46 52 64 - red 191 97 106 - green 163 190 140 - yellow 235 203 139 - blue 129 161 193 - magenta 180 142 173 - orange 208 135 112 - cyan 136 192 208 - black 59 66 82 - white 229 233 240 + text_unselected { + base 229 233 240 + background 59 66 82 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 163 190 140 + emphasis_3 180 142 173 + } + text_selected { + base 229 233 240 + background 46 52 64 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 163 190 140 + emphasis_3 180 142 173 + } + ribbon_selected { + base 59 66 82 + background 163 190 140 + emphasis_0 191 97 106 + emphasis_1 208 135 112 + emphasis_2 180 142 173 + emphasis_3 129 161 193 + } + ribbon_unselected { + base 59 66 82 + background 216 222 233 + emphasis_0 191 97 106 + emphasis_1 229 233 240 + emphasis_2 129 161 193 + emphasis_3 180 142 173 + } + table_title { + base 163 190 140 + background 0 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 163 190 140 + emphasis_3 180 142 173 + } + table_cell_selected { + base 229 233 240 + background 46 52 64 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 163 190 140 + emphasis_3 180 142 173 + } + table_cell_unselected { + base 229 233 240 + background 59 66 82 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 163 190 140 + emphasis_3 180 142 173 + } + list_selected { + base 229 233 240 + background 46 52 64 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 163 190 140 + emphasis_3 180 142 173 + } + list_unselected { + base 229 233 240 + background 59 66 82 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 163 190 140 + emphasis_3 180 142 173 + } + frame_selected { + base 163 190 140 + background 0 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 180 142 173 + emphasis_3 0 + } + frame_highlight { + base 208 135 112 + background 0 + emphasis_0 208 135 112 + emphasis_1 208 135 112 + emphasis_2 208 135 112 + emphasis_3 208 135 112 + } + exit_code_success { + base 163 190 140 + background 0 + emphasis_0 136 192 208 + emphasis_1 59 66 82 + emphasis_2 180 142 173 + emphasis_3 129 161 193 + } + exit_code_error { + base 191 97 106 + background 0 + emphasis_0 235 203 139 + emphasis_1 0 + emphasis_2 0 + emphasis_3 0 + } + multiplayer_user_colors { + player_1 180 142 173 + player_2 129 161 193 + player_3 0 + player_4 235 203 139 + player_5 136 192 208 + player_6 0 + player_7 191 97 106 + player_8 0 + player_9 0 + player_10 0 + } } } diff --git a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_multiple_theme_definitions.snap b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_multiple_theme_definitions.snap index f8d7d38b..abae11d8 100644 --- a/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_multiple_theme_definitions.snap +++ b/zellij-utils/src/kdl/snapshots/zellij_utils__kdl__themes_to_string_with_multiple_theme_definitions.snap @@ -1,33 +1,242 @@ --- source: zellij-utils/src/kdl/mod.rs -assertion_line: 4821 expression: serialized.to_string() --- themes { dracula { - fg 248 248 242 - bg 40 42 54 - red 255 85 85 - green 80 250 123 - yellow 241 250 140 - blue 98 114 164 - magenta 255 121 198 - orange 255 184 108 - cyan 139 233 253 - black 0 0 0 - white 255 255 255 + text_unselected { + base 255 255 255 + background 0 0 0 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 80 250 123 + emphasis_3 255 121 198 + } + text_selected { + base 255 255 255 + background 40 42 54 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 80 250 123 + emphasis_3 255 121 198 + } + ribbon_selected { + base 0 0 0 + background 80 250 123 + emphasis_0 255 85 85 + emphasis_1 255 184 108 + emphasis_2 255 121 198 + emphasis_3 98 114 164 + } + ribbon_unselected { + base 0 0 0 + background 248 248 242 + emphasis_0 255 85 85 + emphasis_1 255 255 255 + emphasis_2 98 114 164 + emphasis_3 255 121 198 + } + table_title { + base 80 250 123 + background 0 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 80 250 123 + emphasis_3 255 121 198 + } + table_cell_selected { + base 255 255 255 + background 40 42 54 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 80 250 123 + emphasis_3 255 121 198 + } + table_cell_unselected { + base 255 255 255 + background 0 0 0 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 80 250 123 + emphasis_3 255 121 198 + } + list_selected { + base 255 255 255 + background 40 42 54 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 80 250 123 + emphasis_3 255 121 198 + } + list_unselected { + base 255 255 255 + background 0 0 0 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 80 250 123 + emphasis_3 255 121 198 + } + frame_selected { + base 80 250 123 + background 0 + emphasis_0 255 184 108 + emphasis_1 139 233 253 + emphasis_2 255 121 198 + emphasis_3 0 + } + frame_highlight { + base 255 184 108 + background 0 + emphasis_0 255 184 108 + emphasis_1 255 184 108 + emphasis_2 255 184 108 + emphasis_3 255 184 108 + } + exit_code_success { + base 80 250 123 + background 0 + emphasis_0 139 233 253 + emphasis_1 0 0 0 + emphasis_2 255 121 198 + emphasis_3 98 114 164 + } + exit_code_error { + base 255 85 85 + background 0 + emphasis_0 241 250 140 + emphasis_1 0 + emphasis_2 0 + emphasis_3 0 + } + multiplayer_user_colors { + player_1 255 121 198 + player_2 98 114 164 + player_3 0 + player_4 241 250 140 + player_5 139 233 253 + player_6 0 + player_7 255 85 85 + player_8 0 + player_9 0 + player_10 0 + } } nord { - fg 216 222 233 - bg 46 52 64 - red 191 97 106 - green 163 190 140 - yellow 235 203 139 - blue 129 161 193 - magenta 180 142 173 - orange 208 135 112 - cyan 136 192 208 - black 59 66 82 - white 229 233 240 + text_unselected { + base 229 233 240 + background 59 66 82 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 163 190 140 + emphasis_3 180 142 173 + } + text_selected { + base 229 233 240 + background 46 52 64 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 163 190 140 + emphasis_3 180 142 173 + } + ribbon_selected { + base 59 66 82 + background 163 190 140 + emphasis_0 191 97 106 + emphasis_1 208 135 112 + emphasis_2 180 142 173 + emphasis_3 129 161 193 + } + ribbon_unselected { + base 59 66 82 + background 216 222 233 + emphasis_0 191 97 106 + emphasis_1 229 233 240 + emphasis_2 129 161 193 + emphasis_3 180 142 173 + } + table_title { + base 163 190 140 + background 0 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 163 190 140 + emphasis_3 180 142 173 + } + table_cell_selected { + base 229 233 240 + background 46 52 64 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 163 190 140 + emphasis_3 180 142 173 + } + table_cell_unselected { + base 229 233 240 + background 59 66 82 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 163 190 140 + emphasis_3 180 142 173 + } + list_selected { + base 229 233 240 + background 46 52 64 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 163 190 140 + emphasis_3 180 142 173 + } + list_unselected { + base 229 233 240 + background 59 66 82 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 163 190 140 + emphasis_3 180 142 173 + } + frame_selected { + base 163 190 140 + background 0 + emphasis_0 208 135 112 + emphasis_1 136 192 208 + emphasis_2 180 142 173 + emphasis_3 0 + } + frame_highlight { + base 208 135 112 + background 0 + emphasis_0 208 135 112 + emphasis_1 208 135 112 + emphasis_2 208 135 112 + emphasis_3 208 135 112 + } + exit_code_success { + base 163 190 140 + background 0 + emphasis_0 136 192 208 + emphasis_1 59 66 82 + emphasis_2 180 142 173 + emphasis_3 129 161 193 + } + exit_code_error { + base 191 97 106 + background 0 + emphasis_0 235 203 139 + emphasis_1 0 + emphasis_2 0 + emphasis_3 0 + } + multiplayer_user_colors { + player_1 180 142 173 + player_2 129 161 193 + player_3 0 + player_4 235 203 139 + player_5 136 192 208 + player_6 0 + player_7 191 97 106 + player_8 0 + player_9 0 + player_10 0 + } } } diff --git a/zellij-utils/src/plugin_api/event.rs b/zellij-utils/src/plugin_api/event.rs index 08db3d6e..df80e89d 100644 --- a/zellij-utils/src/plugin_api/event.rs +++ b/zellij-utils/src/plugin_api/event.rs @@ -1458,7 +1458,9 @@ fn serialize_mode_update_event_with_non_default_values() { silver: PaletteColor::EightBit(2), pink: PaletteColor::EightBit(2), brown: PaletteColor::Rgb((222, 221, 220)), - }, + } + .into(), + // TODO: replace default rounded_corners: true, hide_session_name: false, }, diff --git a/zellij-utils/src/plugin_api/style.proto b/zellij-utils/src/plugin_api/style.proto index f4f3b758..cfea362e 100644 --- a/zellij-utils/src/plugin_api/style.proto +++ b/zellij-utils/src/plugin_api/style.proto @@ -3,9 +3,10 @@ syntax = "proto3"; package api.style; message Style { - Palette palette = 1; + Palette palette = 1 [deprecated = true]; bool rounded_corners = 2; bool hide_session_name = 3; + Styling styling = 4; } message Palette { @@ -52,3 +53,21 @@ enum ThemeHue { Dark = 0; Light = 1; } + +message Styling { + repeated Color text_unselected = 1; + repeated Color text_selected = 2; + repeated Color ribbon_unselected = 3; + repeated Color ribbon_selected =4; + repeated Color table_title = 5; + repeated Color table_cell_unselected = 6; + repeated Color table_cell_selected = 7; + repeated Color list_unselected = 8; + repeated Color list_selected = 9; + repeated Color frame_unselected = 10; + repeated Color frame_selected = 11; + repeated Color frame_highlight = 12; + repeated Color exit_code_success = 13; + repeated Color exit_code_error = 14; + repeated Color multiplayer_user_colors = 15; +} diff --git a/zellij-utils/src/plugin_api/style.rs b/zellij-utils/src/plugin_api/style.rs index 1e3ba677..eb9eebcf 100644 --- a/zellij-utils/src/plugin_api/style.rs +++ b/zellij-utils/src/plugin_api/style.rs @@ -1,9 +1,11 @@ use super::generated_api::api::style::{ color::Payload as ProtobufColorPayload, Color as ProtobufColor, ColorType as ProtobufColorType, Palette as ProtobufPalette, RgbColorPayload as ProtobufRgbColorPayload, Style as ProtobufStyle, - ThemeHue as ProtobufThemeHue, + Styling as ProtobufStyling, ThemeHue as ProtobufThemeHue, +}; +use crate::data::{ + MultiplayerColors, Palette, PaletteColor, Style, StyleDeclaration, Styling, ThemeHue, }; -use crate::data::{Palette, PaletteColor, Style, ThemeHue}; use crate::errors::prelude::*; use std::convert::TryFrom; @@ -11,24 +13,183 @@ use std::convert::TryFrom; impl TryFrom<ProtobufStyle> for Style { type Error = &'static str; fn try_from(protobuf_style: ProtobufStyle) -> Result<Self, &'static str> { + let s = protobuf_style + .styling + .ok_or("malformed style payload")? + .try_into()?; Ok(Style { - colors: protobuf_style - .palette - .ok_or("malformed style payload")? - .try_into()?, + colors: s, rounded_corners: protobuf_style.rounded_corners, hide_session_name: protobuf_style.hide_session_name, }) } } +#[allow(deprecated)] impl TryFrom<Style> for ProtobufStyle { type Error = &'static str; fn try_from(style: Style) -> Result<Self, &'static str> { + let s = ProtobufStyling::try_from(style.colors)?; + let palette = Palette::try_from(style.colors).map_err(|_| "malformed style payload")?; Ok(ProtobufStyle { - palette: Some(style.colors.try_into()?), + palette: Some(palette.try_into()?), rounded_corners: style.rounded_corners, hide_session_name: style.hide_session_name, + styling: Some(s), + }) + } +} + +fn to_array<T, const N: usize>(v: Vec<T>) -> std::result::Result<[T; N], &'static str> { + v.try_into() + .map_err(|_| "Could not obtain array from protobuf field") +} + +fn to_style_declaration( + parsed_array: Result<[PaletteColor; 6], &'static str>, +) -> Result<StyleDeclaration, &'static str> { + parsed_array.map(|arr| StyleDeclaration { + base: arr[0], + background: arr[1], + emphasis_0: arr[2], + emphasis_1: arr[3], + emphasis_2: arr[4], + emphasis_3: arr[5], + }) +} + +fn to_multiplayer_colors( + parsed_array: Result<[PaletteColor; 10], &'static str>, +) -> Result<MultiplayerColors, &'static str> { + parsed_array.map(|arr| MultiplayerColors { + player_1: arr[0], + player_2: arr[1], + player_3: arr[2], + player_4: arr[3], + player_5: arr[4], + player_6: arr[5], + player_7: arr[6], + player_8: arr[7], + player_9: arr[8], + player_10: arr[9], + }) +} + +#[macro_export] +macro_rules! color_definitions { + ($proto:expr, $declaration:ident, $size:expr) => { + to_style_declaration(to_array::<PaletteColor, $size>( + $proto + .$declaration + .into_iter() + .map(PaletteColor::try_from) + .collect::<Result<Vec<PaletteColor>, _>>()?, + ))? + }; +} + +#[macro_export] +macro_rules! multiplayer_colors { + ($proto:expr, $size: expr) => { + to_multiplayer_colors(to_array::<PaletteColor, $size>( + $proto + .multiplayer_user_colors + .into_iter() + .map(PaletteColor::try_from) + .collect::<Result<Vec<PaletteColor>, _>>()?, + ))? + }; +} + +impl TryFrom<ProtobufStyling> for Styling { + type Error = &'static str; + + fn try_from(proto: ProtobufStyling) -> std::result::Result<Self, Self::Error> { + let frame_unselected = if proto.frame_unselected.len() > 0 { + Some(color_definitions!(proto, frame_unselected, 6)) + } else { + None + }; + + Ok(Styling { + text_unselected: color_definitions!(proto, text_unselected, 6), + text_selected: color_definitions!(proto, text_selected, 6), + ribbon_unselected: color_definitions!(proto, ribbon_unselected, 6), + ribbon_selected: color_definitions!(proto, ribbon_selected, 6), + table_title: color_definitions!(proto, table_title, 6), + table_cell_unselected: color_definitions!(proto, table_cell_unselected, 6), + table_cell_selected: color_definitions!(proto, table_cell_selected, 6), + list_unselected: color_definitions!(proto, list_unselected, 6), + list_selected: color_definitions!(proto, list_selected, 6), + frame_unselected, + frame_selected: color_definitions!(proto, frame_selected, 6), + frame_highlight: color_definitions!(proto, frame_highlight, 6), + exit_code_success: color_definitions!(proto, exit_code_success, 6), + exit_code_error: color_definitions!(proto, exit_code_error, 6), + multiplayer_user_colors: multiplayer_colors!(proto, 10), + }) + } +} + +impl TryFrom<StyleDeclaration> for Vec<ProtobufColor> { + type Error = &'static str; + + fn try_from(colors: StyleDeclaration) -> std::result::Result<Self, Self::Error> { + Ok(vec![ + colors.base.try_into()?, + colors.background.try_into()?, + colors.emphasis_0.try_into()?, + colors.emphasis_1.try_into()?, + colors.emphasis_2.try_into()?, + colors.emphasis_3.try_into()?, + ]) + } +} + +impl TryFrom<MultiplayerColors> for Vec<ProtobufColor> { + type Error = &'static str; + + fn try_from(value: MultiplayerColors) -> std::result::Result<Self, Self::Error> { + Ok(vec![ + value.player_1.try_into()?, + value.player_2.try_into()?, + value.player_3.try_into()?, + value.player_4.try_into()?, + value.player_5.try_into()?, + value.player_6.try_into()?, + value.player_7.try_into()?, + value.player_8.try_into()?, + value.player_9.try_into()?, + value.player_10.try_into()?, + ]) + } +} + +impl TryFrom<Styling> for ProtobufStyling { + type Error = &'static str; + + fn try_from(style: Styling) -> std::result::Result<Self, Self::Error> { + let frame_unselected_vec = match style.frame_unselected { + None => Ok(Vec::new()), + Some(frame_unselected) => frame_unselected.try_into(), + }; + + Ok(ProtobufStyling { + text_unselected: style.text_unselected.try_into()?, + text_selected: style.text_selected.try_into()?, + ribbon_unselected: style.ribbon_unselected.try_into()?, + ribbon_selected: style.ribbon_selected.try_into()?, + table_title: style.table_title.try_into()?, + table_cell_unselected: style.table_cell_unselected.try_into()?, + table_cell_selected: style.table_cell_selected.try_into()?, + list_unselected: style.list_unselected.try_into()?, + list_selected: style.list_selected.try_into()?, + frame_unselected: frame_unselected_vec?, + frame_selected: style.frame_selected.try_into()?, + frame_highlight: style.frame_highlight.try_into()?, + exit_code_success: style.exit_code_success.try_into()?, + exit_code_error: style.exit_code_error.try_into()?, + multiplayer_user_colors: style.multiplayer_user_colors.try_into()?, }) } } diff --git a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap index 05e35cb2..84dd016e 100644 --- a/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap +++ b/zellij-utils/src/snapshots/zellij_utils__setup__setup_test__layout_themes_override_config_themes.snap @@ -1,6 +1,5 @@ --- source: zellij-utils/src/setup.rs -assertion_line: 841 expression: "format!(\"{:#?}\", config)" --- Config { @@ -5614,310 +5613,1786 @@ Config { }, themes: { "other-theme-from-config": Theme { - palette: Palette { - source: Default, - theme_hue: Dark, - fg: Rgb( - ( - 2, - 2, - 2, + sourced_from_external_file: false, + palette: Styling { + text_unselected: StyleDeclaration { + base: Rgb( + ( + 2, + 2, + 2, + ), ), - ), - bg: Rgb( - ( - 2, - 2, - 2, + background: Rgb( + ( + 2, + 2, + 2, + ), ), - ), - black: Rgb( - ( - 2, - 2, - 2, + emphasis_0: Rgb( + ( + 2, + 2, + 2, + ), ), - ), - red: Rgb( - ( - 2, - 2, - 2, + emphasis_1: Rgb( + ( + 2, + 2, + 2, + ), ), - ), - green: Rgb( - ( - 2, - 2, - 2, + emphasis_2: Rgb( + ( + 2, + 2, + 2, + ), ), - ), - yellow: Rgb( - ( - 2, - 2, - 2, + emphasis_3: Rgb( + ( + 2, + 2, + 2, + ), ), - ), - blue: Rgb( - ( - 2, - 2, - 2, + }, + text_selected: StyleDeclaration { + base: Rgb( + ( + 2, + 2, + 2, + ), ), - ), - magenta: Rgb( - ( - 2, - 2, - 2, + background: Rgb( + ( + 2, + 2, + 2, + ), ), - ), - cyan: Rgb( - ( - 2, - 2, - 2, + emphasis_0: Rgb( + ( + 2, + 2, + 2, + ), ), - ), - white: Rgb( - ( - 2, - 2, - 2, + emphasis_1: Rgb( + ( + 2, + 2, + 2, + ), ), - ), - orange: Rgb( - ( - 2, - 2, - 2, + emphasis_2: Rgb( + ( + 2, + 2, + 2, + ), ), - ), - gray: EightBit( - 0, - ), - purple: EightBit( - 0, - ), - gold: EightBit( - 0, - ), - silver: EightBit( - 0, - ), - pink: EightBit( - 0, - ), - brown: EightBit( - 0, - ), + emphasis_3: Rgb( + ( + 2, + 2, + 2, + ), + ), + }, + ribbon_unselected: StyleDeclaration { + base: Rgb( + ( + 2, + 2, + 2, + ), + ), + background: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_0: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_1: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_2: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_3: Rgb( + ( + 2, + 2, + 2, + ), + ), + }, + ribbon_selected: StyleDeclaration { + base: Rgb( + ( + 2, + 2, + 2, + ), + ), + background: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_0: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_1: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_2: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_3: Rgb( + ( + 2, + 2, + 2, + ), + ), + }, + table_title: StyleDeclaration { + base: Rgb( + ( + 2, + 2, + 2, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_1: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_2: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_3: Rgb( + ( + 2, + 2, + 2, + ), + ), + }, + table_cell_unselected: StyleDeclaration { + base: Rgb( + ( + 2, + 2, + 2, + ), + ), + background: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_0: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_1: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_2: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_3: Rgb( + ( + 2, + 2, + 2, + ), + ), + }, + table_cell_selected: StyleDeclaration { + base: Rgb( + ( + 2, + 2, + 2, + ), + ), + background: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_0: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_1: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_2: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_3: Rgb( + ( + 2, + 2, + 2, + ), + ), + }, + list_unselected: StyleDeclaration { + base: Rgb( + ( + 2, + 2, + 2, + ), + ), + background: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_0: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_1: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_2: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_3: Rgb( + ( + 2, + 2, + 2, + ), + ), + }, + list_selected: StyleDeclaration { + base: Rgb( + ( + 2, + 2, + 2, + ), + ), + background: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_0: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_1: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_2: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_3: Rgb( + ( + 2, + 2, + 2, + ), + ), + }, + frame_unselected: None, + frame_selected: StyleDeclaration { + base: Rgb( + ( + 2, + 2, + 2, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_1: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_2: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_3: EightBit( + 0, + ), + }, + frame_highlight: StyleDeclaration { + base: Rgb( + ( + 2, + 2, + 2, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_1: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_2: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_3: Rgb( + ( + 2, + 2, + 2, + ), + ), + }, + exit_code_success: StyleDeclaration { + base: Rgb( + ( + 2, + 2, + 2, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_1: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_2: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_3: Rgb( + ( + 2, + 2, + 2, + ), + ), + }, + exit_code_error: StyleDeclaration { + base: Rgb( + ( + 2, + 2, + 2, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 2, + 2, + 2, + ), + ), + emphasis_1: EightBit( + 0, + ), + emphasis_2: EightBit( + 0, + ), + emphasis_3: EightBit( + 0, + ), + }, + multiplayer_user_colors: MultiplayerColors { + player_1: Rgb( + ( + 2, + 2, + 2, + ), + ), + player_2: Rgb( + ( + 2, + 2, + 2, + ), + ), + player_3: EightBit( + 0, + ), + player_4: Rgb( + ( + 2, + 2, + 2, + ), + ), + player_5: Rgb( + ( + 2, + 2, + 2, + ), + ), + player_6: EightBit( + 0, + ), + player_7: Rgb( + ( + 2, + 2, + 2, + ), + ), + player_8: EightBit( + 0, + ), + player_9: EightBit( + 0, + ), + player_10: EightBit( + 0, + ), + }, }, - sourced_from_external_file: false, }, "theme-from-config": Theme { - palette: Palette { - source: Default, - theme_hue: Dark, - fg: Rgb( - ( - 1, - 1, - 1, + sourced_from_external_file: false, + palette: Styling { + text_unselected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - bg: Rgb( - ( - 1, - 1, - 1, + background: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - black: Rgb( - ( - 1, - 1, - 1, + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - red: Rgb( - ( - 1, - 1, - 1, + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - green: Rgb( - ( - 1, - 1, - 1, + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - yellow: Rgb( - ( - 1, - 1, - 1, + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - blue: Rgb( - ( - 1, - 1, - 1, + }, + text_selected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - magenta: Rgb( - ( - 1, - 1, - 1, + background: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - cyan: Rgb( - ( - 1, - 1, - 1, + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - white: Rgb( - ( - 1, - 1, - 1, + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - orange: Rgb( - ( - 1, - 1, - 1, + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - gray: EightBit( - 0, - ), - purple: EightBit( - 0, - ), - gold: EightBit( - 0, - ), - silver: EightBit( - 0, - ), - pink: EightBit( - 0, - ), - brown: EightBit( - 0, - ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + ribbon_unselected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + ribbon_selected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + table_title: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + table_cell_unselected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + table_cell_selected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + list_unselected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + list_selected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + frame_unselected: None, + frame_selected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: EightBit( + 0, + ), + }, + frame_highlight: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + exit_code_success: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + exit_code_error: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: EightBit( + 0, + ), + emphasis_2: EightBit( + 0, + ), + emphasis_3: EightBit( + 0, + ), + }, + multiplayer_user_colors: MultiplayerColors { + player_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + player_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + player_3: EightBit( + 0, + ), + player_4: Rgb( + ( + 1, + 1, + 1, + ), + ), + player_5: Rgb( + ( + 1, + 1, + 1, + ), + ), + player_6: EightBit( + 0, + ), + player_7: Rgb( + ( + 1, + 1, + 1, + ), + ), + player_8: EightBit( + 0, + ), + player_9: EightBit( + 0, + ), + player_10: EightBit( + 0, + ), + }, }, - sourced_from_external_file: false, }, "theme-from-layout": Theme { - palette: Palette { - source: Default, - theme_hue: Dark, - fg: Rgb( - ( - 1, - 1, - 1, + sourced_from_external_file: false, + palette: Styling { + text_unselected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - bg: Rgb( - ( - 1, - 1, - 1, + background: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - black: Rgb( - ( - 1, - 1, - 1, + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - red: Rgb( - ( - 1, - 1, - 1, + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - green: Rgb( - ( - 1, - 1, - 1, + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - yellow: Rgb( - ( - 1, - 1, - 1, + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - blue: Rgb( - ( - 1, - 1, - 1, + }, + text_selected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - magenta: Rgb( - ( - 1, - 1, - 1, + background: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - cyan: Rgb( - ( - 1, - 1, - 1, + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - white: Rgb( - ( - 1, - 1, - 1, + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - orange: Rgb( - ( - 1, - 1, - 1, + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), ), - ), - gray: EightBit( - 0, - ), - purple: EightBit( - 0, - ), - gold: EightBit( - 0, - ), - silver: EightBit( - 0, - ), - pink: EightBit( - 0, - ), - brown: EightBit( - 0, - ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + ribbon_unselected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + ribbon_selected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + table_title: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + table_cell_unselected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + table_cell_selected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + list_unselected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + list_selected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + frame_unselected: None, + frame_selected: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: EightBit( + 0, + ), + }, + frame_highlight: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + exit_code_success: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_3: Rgb( + ( + 1, + 1, + 1, + ), + ), + }, + exit_code_error: StyleDeclaration { + base: Rgb( + ( + 1, + 1, + 1, + ), + ), + background: EightBit( + 0, + ), + emphasis_0: Rgb( + ( + 1, + 1, + 1, + ), + ), + emphasis_1: EightBit( + 0, + ), + emphasis_2: EightBit( + 0, + ), + emphasis_3: EightBit( + 0, + ), + }, + multiplayer_user_colors: MultiplayerColors { + player_1: Rgb( + ( + 1, + 1, + 1, + ), + ), + player_2: Rgb( + ( + 1, + 1, + 1, + ), + ), + player_3: EightBit( + 0, + ), + player_4: Rgb( + ( + 1, + 1, + 1, + ), + ), + player_5: Rgb( + ( + 1, + 1, + 1, + ), + ), + player_6: EightBit( + 0, + ), + player_7: Rgb( + ( + 1, + 1, + 1, + ), + ), + player_8: EightBit( + 0, + ), + player_9: EightBit( + 0, + ), + player_10: EightBit( + 0, + ), + }, }, - sourced_from_external_file: false, }, }, plugins: PluginAliases { |
