Skip to content

Commit 7d92b48

Browse files
committed
fix image backend detection
1 parent 8397b9d commit 7d92b48

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

Diff for: src/onefetch/image_backends/kitty.rs

-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use {
55
c_void, ioctl, poll, pollfd, read, tcgetattr, tcsetattr, termios, winsize, ECHO, ICANON,
66
POLLIN, STDIN_FILENO, STDOUT_FILENO, TCSANOW, TIOCGWINSZ,
77
},
8-
std::env,
98
std::io::{stdout, Write},
109
std::time::Instant,
1110
};
@@ -18,10 +17,6 @@ impl KittyBackend {
1817
}
1918

2019
pub fn supported() -> bool {
21-
if !env::var("KITTY_WINDOW_ID").unwrap_or_else(|_| "".to_string()).is_empty() {
22-
return true;
23-
}
24-
2520
// save terminal attributes and disable canonical input processing mode
2621
let old_attributes = unsafe {
2722
let mut old_attributes: termios = std::mem::zeroed();

Diff for: src/onefetch/image_backends/mod.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,20 @@ pub trait ImageBackend {
1212
fn add_image(&self, lines: Vec<String>, image: &DynamicImage, colors: usize) -> Result<String>;
1313
}
1414

15-
#[cfg(not(windows))]
1615
pub fn get_best_backend() -> Option<Box<dyn ImageBackend>> {
17-
if sixel::SixelBackend::supported() {
18-
Some(Box::new(sixel::SixelBackend::new()))
19-
} else if kitty::KittyBackend::supported() {
16+
#[cfg(not(windows))]
17+
if kitty::KittyBackend::supported() {
2018
Some(Box::new(kitty::KittyBackend::new()))
2119
} else if iterm::ITermBackend::supported() {
2220
Some(Box::new(iterm::ITermBackend::new()))
21+
} else if sixel::SixelBackend::supported() {
22+
Some(Box::new(sixel::SixelBackend::new()))
2323
} else {
2424
None
2525
}
26+
27+
#[cfg(windows)]
28+
None
2629
}
2730

2831
pub fn get_image_backend(backend_name: &str) -> Option<Box<dyn ImageBackend>> {
@@ -33,12 +36,8 @@ pub fn get_image_backend(backend_name: &str) -> Option<Box<dyn ImageBackend>> {
3336
"sixel" => Box::new(sixel::SixelBackend::new()) as Box<dyn ImageBackend>,
3437
_ => unreachable!(),
3538
});
39+
3640
#[cfg(windows)]
3741
let backend = None;
3842
backend
3943
}
40-
41-
#[cfg(windows)]
42-
pub fn get_best_backend() -> Option<Box<dyn ImageBackend>> {
43-
None
44-
}

0 commit comments

Comments
 (0)