aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKunal Mohan <kunalmohan99@gmail.com>2021-05-04 20:48:28 +0530
committerKunal Mohan <kunalmohan99@gmail.com>2021-05-04 20:48:28 +0530
commitc1dd2c588e9bad58a760a06076c6689776d7d43d (patch)
treed12a5464dec63c3c4d8c8935c95593cefead5fa6 /src
parentUse ZELLIJ_SOCKET_DIR env variable and make user specific tmp dir (diff)
downloadsl0ppij-c1dd2c588e9bad58a760a06076c6689776d7d43d.tar.gz
sl0ppij-c1dd2c588e9bad58a760a06076c6689776d7d43d.tar.xz
sl0ppij-c1dd2c588e9bad58a760a06076c6689776d7d43d.zip
Fix after rebase
Diffstat (limited to 'src')
-rw-r--r--src/common/os_input_output.rs49
-rw-r--r--src/common/utils/shared.rs4
-rw-r--r--src/tests/fakes.rs39
3 files changed, 8 insertions, 84 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
diff --git a/src/tests/fakes.rs b/src/tests/fakes.rs
index 711d48ad..4c780410 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()
}
}