summaryrefslogtreecommitdiffstats
path: root/zellij-tile/src
diff options
context:
space:
mode:
authordenis <denismaximov98@gmail.com>2021-03-27 15:30:53 +0200
committerdenis <denismaximov98@gmail.com>2021-03-27 15:30:53 +0200
commit6e276ae386f0f7e9dd3a4e1095d26e17f6c6401e (patch)
treee93c0e2c241e336baddbc2f124d8f09a54b3cd7f /zellij-tile/src
parentb71315b03638c630b2e70dac1b464dd79d84d781 (diff)
wip: move Palette out of zellij-tile
Diffstat (limited to 'zellij-tile/src')
-rw-r--r--zellij-tile/src/data.rs98
1 files changed, 14 insertions, 84 deletions
diff --git a/zellij-tile/src/data.rs b/zellij-tile/src/data.rs
index 315bc0911..16f025318 100644
--- a/zellij-tile/src/data.rs
+++ b/zellij-tile/src/data.rs
@@ -1,89 +1,5 @@
-use colors_transform::{Color, Rgb};
use serde::{Deserialize, Serialize};
use strum_macros::{EnumDiscriminants, EnumIter, EnumString, ToString};
-use xrdb::Colors;
-pub mod colors {
- pub const WHITE: (u8, u8, u8) = (238, 238, 238);
- pub const GREEN: (u8, u8, u8) = (175, 255, 0);
- pub const GRAY: (u8, u8, u8) = (68, 68, 68);
- pub const BRIGHT_GRAY: (u8, u8, u8) = (138, 138, 138);
- pub const RED: (u8, u8, u8) = (135, 0, 0);
- pub const BLACK: (u8, u8, u8) = (0, 0, 0);
-}
-
-#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
-pub struct Palette {
- pub fg: (u8, u8, u8),
- pub bg: (u8, u8, u8),
- pub black: (u8, u8, u8),
- pub red: (u8, u8, u8),
- pub green: (u8, u8, u8),
- pub yellow: (u8, u8, u8),
- pub blue: (u8, u8, u8),
- pub magenta: (u8, u8, u8),
- pub cyan: (u8, u8, u8),
- pub white: (u8, u8, u8),
-}
-
-impl Palette {
- pub fn new() -> Self {
- let palette = match Colors::new("xresources") {
- Some(colors) => {
- let fg = colors.fg.unwrap();
- let fg_imm = &fg;
- let fg_hex: &str = &fg_imm;
- let fg = Rgb::from_hex_str(fg_hex).unwrap().as_tuple();
- let fg = (fg.0 as u8, fg.1 as u8, fg.2 as u8);
- let bg = colors.bg.unwrap();
- let bg_imm = &bg;
- let bg_hex: &str = &bg_imm;
- let bg = Rgb::from_hex_str(bg_hex).unwrap().as_tuple();
- let bg = (bg.0 as u8, bg.1 as u8, bg.2 as u8);
- let colors: Vec<(u8, u8, u8)> = colors
- .colors
- .iter()
- .map(|c| {
- let c = c.clone();
- let imm_str = &c.unwrap();
- let hex_str: &str = &imm_str;
- let rgb = Rgb::from_hex_str(hex_str).unwrap().as_tuple();
- (rgb.0 as u8, rgb.1 as u8, rgb.2 as u8)
- })
- .collect();
- Self {
- fg,
- bg,
- black: colors[0],
- red: colors[1],
- green: colors[2],
- yellow: colors[3],
- blue: colors[4],
- magenta: colors[5],
- cyan: colors[6],
- white: colors[7],
- }
- }
- None => Self {
- fg: colors::BRIGHT_GRAY,
- bg: colors::BLACK,
- black: colors::BLACK,
- red: colors::RED,
- green: colors::GREEN,
- yellow: colors::GRAY,
- blue: colors::GRAY,
- magenta: colors::GRAY,
- cyan: colors::GRAY,
- white: colors::WHITE,
- },
- };
- palette
- }
-}
-impl Default for Palette {
- fn default() -> Palette {
- Palette::new()
- }
-}
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Key {
@@ -142,6 +58,20 @@ impl Default for InputMode {
}
}
+#[derive(Clone, Copy, Default, Debug, Serialize, Deserialize)]
+pub struct Palette {
+ pub fg: (u8, u8, u8),
+ pub bg: (u8, u8, u8),
+ pub black: (u8, u8, u8),
+ pub red: (u8, u8, u8),
+ pub green: (u8, u8, u8),
+ pub yellow: (u8, u8, u8),
+ pub blue: (u8, u8, u8),
+ pub magenta: (u8, u8, u8),
+ pub cyan: (u8, u8, u8),
+ pub white: (u8, u8, u8),
+}
+
/// Represents the contents of the help message that is printed in the status bar,
/// which indicates the current [`InputMode`] and what the keybinds for that mode
/// are. Related to the default `status-bar` plugin.