From f5b33c43c10795661b626330ee86f1979b0957f7 Mon Sep 17 00:00:00 2001 From: Canop Date: Sat, 9 Jul 2022 09:47:24 +0200 Subject: use mio instead of epoll to find terminal's luma For compatibiliy with more unix variants --- Cargo.lock | 17 +++++++++++++---- Cargo.toml | 5 ++--- src/display/luma.rs | 6 ------ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7357191..d8cc4ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ "umask", "unicode-width", "users", - "xterm-query", + "xterm-query 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1863,13 +1863,12 @@ dependencies = [ [[package]] name = "terminal-light" version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f279e95099c18b04b1b5dcab98fa6f2a50908754cbf453ddbb99c392b7d662d1" +source = "git+https://github.com/Canop/terminal-light?branch=mio#2077bc03573b61f967aec001a6f64da78f11a5eb" dependencies = [ "coolor", "crossterm", "thiserror", - "xterm-query", + "xterm-query 0.1.0 (git+https://github.com/Canop/xterm-query?branch=mio)", ] [[package]] @@ -2236,6 +2235,16 @@ dependencies = [ "thiserror", ] +[[package]] +name = "xterm-query" +version = "0.1.0" +source = "git+https://github.com/Canop/xterm-query?branch=mio#0a6bb9438ae532931a363e02922a71c5e775bbe7" +dependencies = [ + "mio", + "nix", + "thiserror", +] + [[package]] name = "yaml-rust" version = "0.4.5" diff --git a/Cargo.toml b/Cargo.toml index 568c8eb..430d549 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,6 +59,7 @@ syntect = { package = "syntect-no-panic", version = "4.6.1" } # see issue #485 tempfile = "3.2" termimad = "0.20.2" terminal-clipboard = { version = "0.3.1", optional = true } +terminal-light = { version = "0.8.1", git = "https://github.com/Canop/terminal-light", branch = "mio" } toml = "0.5" umask = "2.0.0" unicode-width = "0.1.8" @@ -71,9 +72,6 @@ glassbench = "0.3.3" lfs-core = "0.11.0" users = "0.11" -[target.'cfg(target_os = "linux")'.dependencies] -terminal-light = "0.8.1" - [target.'cfg(windows)'.dependencies] is_executable = "1.0.1" @@ -118,5 +116,6 @@ harness = false # syntect = { path = "../syntect" } # syntect-no-panic = { path = "../syntect" } # termimad = { path = "../termimad" } +# terminal-light = { path = "../terminal-light" } # terminal-clipboard = { path = "../terminal-clipboard" } # umask = { path = "../umask" } diff --git a/src/display/luma.rs b/src/display/luma.rs index 479e4c9..c9e9105 100644 --- a/src/display/luma.rs +++ b/src/display/luma.rs @@ -15,7 +15,6 @@ pub enum Luma { /// Return the light of the terminal background, which is a value /// between 0 (black) and 1 (white). -#[cfg(target_os = "linux")] pub fn luma() -> &'static Result { static LUMA: Lazy> = Lazy::new(|| { let luma = time!(Debug, terminal_light::luma()); @@ -25,11 +24,6 @@ pub fn luma() -> &'static Result { &*LUMA } -#[cfg(not(target_os = "linux"))] -pub fn luma() -> Result<&'static f32, &'static str> { - Err("not implemented on this OS") -} - impl Luma { pub fn read() -> Self { match luma() { -- cgit v1.2.3