Skip to content

Commit

Permalink
Merge pull request #135 from mfontanini/sixel-fallback
Browse files Browse the repository at this point in the history
Detect sixel early and fallback to ascii blocks properly
  • Loading branch information
mfontanini authored Jan 14, 2024
2 parents 4bebb1f + 9681f00 commit f4a4450
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/render/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ impl MediaRender {
y: position.row as i16,
use_iterm: false,
use_kitty: false,
#[cfg(feature = "sixel")]
use_sixel: false,
..Default::default()
};
let config = self.mode.apply(config);
Expand All @@ -126,6 +128,8 @@ impl MediaRender {
pub fn detect_terminal_protocol() {
viuer::is_iterm_supported();
viuer::get_kitty_support();
#[cfg(feature = "sixel")]
viuer::is_sixel_supported();
}
}

Expand All @@ -134,6 +138,8 @@ pub enum GraphicsMode {
Iterm2,
Kitty,
AsciiBlocks,
#[cfg(feature = "sixel")]
Sixel,
}

impl Default for GraphicsMode {
Expand All @@ -143,7 +149,11 @@ impl Default for GraphicsMode {
} else if get_kitty_support() != KittySupport::None {
Self::Kitty
} else {
Self::Iterm2
#[cfg(feature = "sixel")]
if viuer::is_sixel_supported() {
return Self::Sixel;
}
Self::AsciiBlocks
}
}
}
Expand All @@ -154,6 +164,8 @@ impl GraphicsMode {
Self::Iterm2 => config.use_iterm = true,
Self::Kitty => config.use_kitty = true,
Self::AsciiBlocks => (),
#[cfg(feature = "sixel")]
Self::Sixel => config.use_sixel = true,
};
config
}
Expand Down

0 comments on commit f4a4450

Please sign in to comment.