diff options
| author | Kunal Mohan <kunalmohan99@gmail.com> | 2021-05-04 20:48:28 +0530 |
|---|---|---|
| committer | Kunal Mohan <kunalmohan99@gmail.com> | 2021-05-04 20:48:28 +0530 |
| commit | c1dd2c588e9bad58a760a06076c6689776d7d43d (patch) | |
| tree | d12a5464dec63c3c4d8c8935c95593cefead5fa6 /src/common | |
| parent | Use ZELLIJ_SOCKET_DIR env variable and make user specific tmp dir (diff) | |
| download | sl0ppij-c1dd2c588e9bad58a760a06076c6689776d7d43d.tar.gz sl0ppij-c1dd2c588e9bad58a760a06076c6689776d7d43d.tar.xz sl0ppij-c1dd2c588e9bad58a760a06076c6689776d7d43d.zip | |
Fix after rebase
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/os_input_output.rs | 49 | ||||
| -rw-r--r-- | src/common/utils/shared.rs | 4 |
2 files changed, 5 insertions, 48 deletions
diff --git a/src/common/os_input_output.rs b/src/common/os_input_output.rs index 7bf39757..9e19f0ee 100644 --- a/src/common/os_input_output.rs +++ b/src/common/os_input_output.rs @@ -6,7 +6,7 @@ use crate::common::{ use crate::errors::ErrorContext; use crate::panes::PositionAndSize; use crate::server::ServerInstruction; -use crate::utils::shared::{default_palette, detect_theme, hex_to_rgb}; +use crate::utils::shared::default_palette; use interprocess::local_socket::LocalSocketStream; use nix::fcntl::{fcntl, FcntlArg, OFlag}; use nix::pty::{forkpty, Winsize}; @@ -22,8 +22,7 @@ use std::os::unix::io::RawFd; use std::path::PathBuf; use std::process::{Child, Command}; use std::sync::{Arc, Mutex}; -use xrdb::Colors; -use zellij_tile::data::{Palette, PaletteSource}; +use zellij_tile::data::Palette; fn into_raw_mode(pid: RawFd) { let mut tio = termios::tcgetattr(pid).expect("could not get terminal attribute"); @@ -262,49 +261,7 @@ impl ServerOsApi for ServerOsInputOutput { Some(Arc::new(Mutex::new(IpcReceiverWithContext::new(stream)))); } fn load_palette(&self) -> Palette { - let palette = match Colors::new("xresources") { - Some(palette) => { - let fg = if let Some(foreground) = palette.fg.as_deref().map(hex_to_rgb) { - foreground - } else { - return default_palette(); - }; - - let bg = if let Some(background) = palette.bg.as_deref().map(hex_to_rgb) { - background - } else { - return default_palette(); - }; - - // NOTE: `16` is the same as the length of `palette.colors`. - let mut colors: [(u8, u8, u8); 16] = [(0, 0, 0); 16]; - for (idx, color) in palette.colors.iter().enumerate() { - if let Some(c) = color { - colors[idx] = hex_to_rgb(c); - } else { - return default_palette(); - } - } - let theme = detect_theme(bg); - Palette { - source: PaletteSource::Xresources, - theme, - 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], - orange: colors[9], - } - } - None => default_palette(), - }; - palette + default_palette() } } diff --git a/src/common/utils/shared.rs b/src/common/utils/shared.rs index 7b4cbcb5..ace5674b 100644 --- a/src/common/utils/shared.rs +++ b/src/common/utils/shared.rs @@ -43,7 +43,7 @@ pub mod colors { pub const BLACK: u8 = 16; } -pub fn hex_to_rgb(hex: &str) -> (u8, u8, u8) { +pub fn _hex_to_rgb(hex: &str) -> (u8, u8, u8) { let rgb = Rgb::from_hex_str(hex) .expect("The passed argument must be a valid hex color") .as_tuple(); @@ -69,7 +69,7 @@ pub fn default_palette() -> Palette { } // Dark magic -pub fn detect_theme(bg: PaletteColor) -> Theme { +pub fn _detect_theme(bg: PaletteColor) -> Theme { match bg { PaletteColor::Rgb((r, g, b)) => { // HSP, P stands for perceived brightness |
