aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/utils
diff options
context:
space:
mode:
authordenis <denismaximov98@gmail.com>2021-04-24 10:21:25 +0300
committerdenis <denismaximov98@gmail.com>2021-04-24 10:21:25 +0300
commitfef466c74b5652f282e837fc5aeb1c68ec15a025 (patch)
tree9fb7c468711170fa259ca92e344acde4328398aa /src/common/utils
parentwip: merge main (diff)
downloadsl0ppij-fef466c74b5652f282e837fc5aeb1c68ec15a025.tar.gz
sl0ppij-fef466c74b5652f282e837fc5aeb1c68ec15a025.tar.xz
sl0ppij-fef466c74b5652f282e837fc5aeb1c68ec15a025.zip
wip: the only way to make the default look like on main is to make more customizable colored elements
Diffstat (limited to 'src/common/utils')
-rw-r--r--src/common/utils/shared.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/common/utils/shared.rs b/src/common/utils/shared.rs
index de15d784..4036a240 100644
--- a/src/common/utils/shared.rs
+++ b/src/common/utils/shared.rs
@@ -6,7 +6,7 @@ use strip_ansi_escapes::strip;
use colors_transform::{Color, Rgb};
use xrdb::Colors;
-use zellij_tile::data::{Palette, Theme};
+use zellij_tile::data::{Palette, Theme, PaletteSource};
fn ansi_len(s: &str) -> usize {
from_utf8(&strip(s.as_bytes()).unwrap())
@@ -51,6 +51,7 @@ pub fn hex_to_rgb(hex: &Option<String>) -> (u8, u8, u8) {
(rgb.0 as u8, rgb.1 as u8, rgb.2 as u8)
}
+// Dark magic
pub fn detect_theme(bg: (u8, u8, u8)) -> Theme {
let (r, g, b) = bg;
// HSP, P stands for perceived brightness
@@ -72,6 +73,7 @@ pub fn load_palette() -> Palette {
let colors: Vec<(u8, u8, u8)> = palette.colors.iter().map(|c| hex_to_rgb(c)).collect();
let theme = detect_theme(bg);
Palette {
+ source: PaletteSource::Xresources,
theme,
fg,
bg,
@@ -86,9 +88,10 @@ pub fn load_palette() -> Palette {
}
}
None => Palette {
+ source: PaletteSource::Default,
theme: Theme::Dark,
fg: colors::BRIGHT_GRAY,
- bg: colors::BLACK,
+ bg: colors::GRAY,
black: colors::BLACK,
red: colors::RED,
green: colors::GREEN,