diff options
-rw-r--r-- | Cargo.lock | 28 | ||||
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/common/os_input_output.rs | 49 | ||||
-rw-r--r-- | src/common/utils/shared.rs | 4 | ||||
-rw-r--r-- | src/tests/fakes.rs | 39 |
5 files changed, 8 insertions, 113 deletions
diff --git a/Cargo.lock b/Cargo.lock index fe7883f39..6f5de9d4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1128,12 +1128,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "pkg-config" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" - -[[package]] name = "polling" version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2250,27 +2244,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" [[package]] -name = "x11" -version = "2.18.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ecd092546cb16f25783a5451538e73afc8d32e242648d54f4ae5459ba1e773" -dependencies = [ - "libc", - "pkg-config", -] - -[[package]] -name = "xrdb" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc2dd91a21c92e87678e22f95956a03bfd314ce3232f39dbedd49dddb50f0c6d" -dependencies = [ - "libc", - "scopeguard", - "x11", -] - -[[package]] name = "yaml-rust" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2312,7 +2285,6 @@ dependencies = [ "vte 0.8.0", "wasmer", "wasmer-wasi", - "xrdb", "zellij-tile", "zellij-tile-extra", ] diff --git a/Cargo.toml b/Cargo.toml index 3b3064c31..fb02f2be0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,6 @@ wasmer = "1.0.0" wasmer-wasi = "1.0.0" interprocess = "1.1.1" names = "0.11.0" -xrdb = "0.1.1" colors-transform = "0.2.5" zellij-tile = { path = "zellij-tile/", version = "1.1.0" } zellij-tile-extra = { path = "zellij-tile-extra/", version="1.0.0" } diff --git a/src/common/os_input_output.rs b/src/common/os_input_output.rs index 7bf39757b..9e19f0ee4 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 7b4cbcb51..ace5674b6 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 diff --git a/src/tests/fakes.rs b/src/tests/fakes.rs index 711d48ad0..4c7804101 100644 --- a/src/tests/fakes.rs +++ b/src/tests/fakes.rs @@ -14,8 +14,8 @@ use crate::os_input_output::{ClientOsApi, ServerOsApi}; use crate::server::ServerInstruction; use crate::tests::possible_tty_inputs::{get_possible_tty_inputs, Bytes}; use crate::tests::utils::commands::{QUIT, SLEEP}; -use crate::utils::shared::colors; -use zellij_tile::data::{Palette, PaletteSource, Theme}; +use crate::utils::shared::default_palette; +use zellij_tile::data::Palette; const MIN_TIME_BETWEEN_SNAPSHOTS: Duration = Duration::from_millis(150); @@ -83,7 +83,6 @@ pub struct FakeInputOutput { receive_instructions_from_client: Arc<Mutex<mpsc::Receiver<(ServerInstruction, ErrorContext)>>>, should_trigger_sigwinch: Arc<(Mutex<bool>, Condvar)>, sigwinch_event: Option<PositionAndSize>, - palette: Arc<Mutex<Palette>>, } impl FakeInputOutput { @@ -98,22 +97,6 @@ impl FakeInputOutput { mpsc::channel(); let send_instructions_to_server = SenderWithContext::new(SenderType::Sender(server_sender)); win_sizes.insert(0, winsize); // 0 is the current terminal - - let palette: Palette = Palette { - source: PaletteSource::Default, - theme: Theme::Dark, - fg: colors::BRIGHT_GRAY, - bg: colors::GRAY, - black: colors::BLACK, - red: colors::RED, - green: colors::GREEN, - yellow: colors::GRAY, - blue: colors::GRAY, - magenta: colors::GRAY, - cyan: colors::GRAY, - white: colors::WHITE, - orange: colors::ORANGE, - }; FakeInputOutput { read_buffers: Arc::new(Mutex::new(HashMap::new())), stdin_writes: Arc::new(Mutex::new(HashMap::new())), @@ -130,7 +113,6 @@ impl FakeInputOutput { send_instructions_to_client, should_trigger_sigwinch: Arc::new((Mutex::new(false), Condvar::new())), sigwinch_event: None, - palette: Arc::new(Mutex::new(palette)), } } pub fn with_tty_inputs(mut self, tty_inputs: HashMap<u16, Bytes>) -> Self { @@ -309,21 +291,6 @@ impl ServerOsApi for FakeInputOutput { fn add_client_sender(&mut self) {} fn update_receiver(&mut self, _stream: LocalSocketStream) {} fn load_palette(&self) -> Palette { - let palette: Palette = Palette { - source: PaletteSource::Default, - theme: Theme::Dark, - fg: colors::BRIGHT_GRAY, - bg: colors::GRAY, - black: colors::BLACK, - red: colors::RED, - green: colors::GREEN, - yellow: colors::GRAY, - blue: colors::GRAY, - magenta: colors::GRAY, - cyan: colors::GRAY, - white: colors::WHITE, - orange: colors::ORANGE, - }; - palette + default_palette() } } |