mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-25 02:06:19 +03:00
Fix after rebase
This commit is contained in:
parent
585b225290
commit
c1dd2c588e
28
Cargo.lock
generated
28
Cargo.lock
generated
@ -1127,12 +1127,6 @@ version = "0.1.0"
|
||||
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"
|
||||
@ -2249,27 +2243,6 @@ version = "0.2.0"
|
||||
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"
|
||||
@ -2312,7 +2285,6 @@ dependencies = [
|
||||
"vte 0.8.0",
|
||||
"wasmer",
|
||||
"wasmer-wasi",
|
||||
"xrdb",
|
||||
"zellij-tile",
|
||||
"zellij-tile-extra",
|
||||
]
|
||||
|
@ -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" }
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user