Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ error-chain = "0.12"
[target.'cfg(windows)'.dependencies]
ansi_term = "0.12"

[target.'cfg(target_os = "linux")'.dependencies]
[target.'cfg(not(windows))'.dependencies]
libc = "0.2.79"
base64 = "0.13.0"

Expand Down
4 changes: 2 additions & 2 deletions src/onefetch/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ pub struct Cli {
impl Cli {
/// Build `Options` from command line arguments.
pub fn new() -> Result<Self> {
#[cfg(target_os = "linux")]
#[cfg(not(windows))]
let possible_backends = ["kitty", "sixel"];
#[cfg(not(target_os = "linux"))]
#[cfg(windows)]
let possible_backends = [];

let matches = App::new(crate_name!())
Expand Down
12 changes: 6 additions & 6 deletions src/onefetch/image_backends/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use image::DynamicImage;

#[cfg(target_os = "linux")]
#[cfg(not(windows))]
pub mod kitty;
#[cfg(target_os = "linux")]
#[cfg(not(windows))]
pub mod sixel;

pub trait ImageBackend {
fn add_image(&self, lines: Vec<String>, image: &DynamicImage) -> String;
}

#[cfg(target_os = "linux")]
#[cfg(not(windows))]
pub fn get_best_backend() -> Option<Box<dyn ImageBackend>> {
if kitty::KittyBackend::supported() {
Some(Box::new(kitty::KittyBackend::new()))
Expand All @@ -21,18 +21,18 @@ pub fn get_best_backend() -> Option<Box<dyn ImageBackend>> {
}

pub fn get_image_backend(backend_name: &str) -> Option<Box<dyn ImageBackend>> {
#[cfg(target_os = "linux")]
#[cfg(not(windows))]
let backend = Some(match backend_name {
"kitty" => Box::new(kitty::KittyBackend::new()) as Box<dyn ImageBackend>,
"sixel" => Box::new(sixel::SixelBackend::new()) as Box<dyn ImageBackend>,
_ => unreachable!(),
});
#[cfg(not(target_os = "linux"))]
#[cfg(windows)]
let backend = None;
backend
}

#[cfg(not(target_os = "linux"))]
#[cfg(windows)]
pub fn get_best_backend() -> Option<Box<dyn ImageBackend>> {
None
}