diff --git a/.github/workflows/merge.yaml b/.github/workflows/merge.yaml index 6d835bd..75a69c4 100644 --- a/.github/workflows/merge.yaml +++ b/.github/workflows/merge.yaml @@ -20,7 +20,7 @@ jobs: components: clippy - name: Run cargo check - run: cargo check --features sixel + run: cargo check - name: Run cargo test run: cargo test diff --git a/Cargo.toml b/Cargo.toml index b93b619..a7def0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ hex = "0.4" fastrand = "2.3" flate2 = "1.0" image = { version = "0.25", features = ["gif", "jpeg", "png"], default-features = false } -icy_sixel = { version = "0.5", optional = true } +icy_sixel = "0.5" merge-struct = "0.1.0" itertools = "0.14" once_cell = "1.19" @@ -46,7 +46,6 @@ rstest = { version = "0.26", default-features = false } [features] default = [] -sixel = ["icy_sixel"] json-schema = ["dep:schemars"] [profile.dev] diff --git a/config-file-schema.json b/config-file-schema.json index 7e2b319..c3f3870 100644 --- a/config-file-schema.json +++ b/config-file-schema.json @@ -276,7 +276,7 @@ ] }, { - "description": "Use the sixel protocol. Note that this requires compiling presenterm using the --features sixel flag.", + "description": "Use the sixel protocol.", "type": "string", "enum": [ "sixel" diff --git a/docs/src/features/images.md b/docs/src/features/images.md index 367e150..8b357ff 100644 --- a/docs/src/features/images.md +++ b/docs/src/features/images.md @@ -11,16 +11,6 @@ the terminals where at least one of these is supported are: * [ghostty](https://ghostty.org/) * [foot](https://codeberg.org/dnkl/foot) -Sixel support is experimental so it needs to be explicitly enabled via the `sixel` configuration flag: - -```bash -cargo build --release --features sixel -``` - -> [!note] -> This feature flag is only needed if your terminal emulator _only_ supports sixel. Many terminals support the kitty or -> iterm2 protocols so using this flag is often not required to get images to render successfully. - --- Things you should know when using image tags in your presentation's markdown are: diff --git a/src/config.rs b/src/config.rs index dfe9f1f..3099ca6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -415,21 +415,16 @@ pub enum ImageProtocol { /// different hosts and therefore can only communicate via terminal escape codes. KittyRemote, - /// Use the sixel protocol. Note that this requires compiling presenterm using the --features - /// sixel flag. + /// Use the sixel protocol. Sixel, /// The default image protocol to use when no other is specified. AsciiBlocks, } -pub struct SixelUnsupported; - -impl TryFrom<&ImageProtocol> for GraphicsMode { - type Error = SixelUnsupported; - - fn try_from(protocol: &ImageProtocol) -> Result { - let mode = match protocol { +impl From<&ImageProtocol> for GraphicsMode { + fn from(protocol: &ImageProtocol) -> Self { + match protocol { ImageProtocol::Auto => { let emulator = TerminalEmulator::detect(); emulator.preferred_protocol() @@ -439,12 +434,8 @@ impl TryFrom<&ImageProtocol> for GraphicsMode { ImageProtocol::KittyLocal => GraphicsMode::Kitty { mode: KittyMode::Local }, ImageProtocol::KittyRemote => GraphicsMode::Kitty { mode: KittyMode::Remote }, ImageProtocol::AsciiBlocks => GraphicsMode::AsciiBlocks, - #[cfg(feature = "sixel")] ImageProtocol::Sixel => GraphicsMode::Sixel, - #[cfg(not(feature = "sixel"))] - ImageProtocol::Sixel => return Err(SixelUnsupported), - }; - Ok(mode) + } } } diff --git a/src/main.rs b/src/main.rs index bdbc670..e729554 100644 --- a/src/main.rs +++ b/src/main.rs @@ -308,13 +308,7 @@ impl CoreComponents { if cli.export_pdf | cli.export_html { GraphicsMode::Raw } else { - let protocol = cli.image_protocol.as_ref().unwrap_or(&config.defaults.image_protocol); - match GraphicsMode::try_from(protocol) { - Ok(mode) => mode, - Err(_) => Cli::command() - .error(ErrorKind::InvalidValue, "sixel support was not enabled during compilation") - .exit(), - } + cli.image_protocol.as_ref().unwrap_or(&config.defaults.image_protocol).into() } } diff --git a/src/terminal/emulator.rs b/src/terminal/emulator.rs index 6a7986c..9f0796a 100644 --- a/src/terminal/emulator.rs +++ b/src/terminal/emulator.rs @@ -55,7 +55,6 @@ impl TerminalEmulator { GraphicsMode::Iterm2Multipart, GraphicsMode::Kitty { mode: KittyMode::Local }, GraphicsMode::Kitty { mode: KittyMode::Remote }, - #[cfg(feature = "sixel")] GraphicsMode::Sixel, GraphicsMode::AsciiBlocks, ]; @@ -103,9 +102,7 @@ impl TerminalEmulator { (GraphicsMode::Iterm2Multipart, Self::Iterm2) => true, // All terminals support ascii protocol (GraphicsMode::AsciiBlocks, _) => true, - #[cfg(feature = "sixel")] (GraphicsMode::Sixel, Self::Foot | Self::Yaft | Self::Mlterm) => true, - #[cfg(feature = "sixel")] (GraphicsMode::Sixel, Self::St | Self::Xterm | Self::Unknown) => capabilities.sixel, _ => false, } diff --git a/src/terminal/image/mod.rs b/src/terminal/image/mod.rs index fd59721..e6f5af6 100644 --- a/src/terminal/image/mod.rs +++ b/src/terminal/image/mod.rs @@ -43,7 +43,6 @@ impl Image { TerminalImage::Kitty(image) => DynamicImage::from(image.as_rgba8()).into(), TerminalImage::Iterm(image) => DynamicImage::from(image.as_rgba8()).into(), TerminalImage::Raw(_) => unreachable!("raw is only used for exports"), - #[cfg(feature = "sixel")] TerminalImage::Sixel(image) => DynamicImage::from(image.as_rgba8()).into(), }; *ascii_image = Some(image.clone()); diff --git a/src/terminal/image/printer.rs b/src/terminal/image/printer.rs index 1612f5f..b312ecb 100644 --- a/src/terminal/image/printer.rs +++ b/src/terminal/image/printer.rs @@ -12,7 +12,10 @@ use crate::{ terminal::{ GraphicsMode, emulator::TerminalEmulator, - image::protocols::iterm::ItermMode, + image::protocols::{ + iterm::ItermMode, + sixel::{SixelImage, SixelPrinter}, + }, printer::{TerminalError, TerminalIo}, }, }; @@ -58,8 +61,7 @@ pub(crate) enum TerminalImage { Iterm(ItermImage), Ascii(AsciiImage), Raw(RawImage), - #[cfg(feature = "sixel")] - Sixel(super::protocols::sixel::SixelImage), + Sixel(SixelImage), } impl fmt::Debug for TerminalImage { @@ -69,7 +71,6 @@ impl fmt::Debug for TerminalImage { Self::Iterm(_) => f.debug_tuple("Iterm").finish(), Self::Ascii(_) => f.debug_tuple("Ascii").finish(), Self::Raw(_) => f.debug_tuple("Raw").finish(), - #[cfg(feature = "sixel")] Self::Sixel(_) => f.debug_tuple("Sixel").finish(), } } @@ -82,7 +83,6 @@ impl ImageProperties for TerminalImage { Self::Iterm(image) => image.dimensions(), Self::Ascii(image) => image.dimensions(), Self::Raw(image) => image.dimensions(), - #[cfg(feature = "sixel")] Self::Sixel(image) => image.dimensions(), } } @@ -94,8 +94,7 @@ pub enum ImagePrinter { Ascii(AsciiPrinter), Raw(RawPrinter), Null, - #[cfg(feature = "sixel")] - Sixel(super::protocols::sixel::SixelPrinter), + Sixel(SixelPrinter), } impl Default for ImagePrinter { @@ -113,8 +112,7 @@ impl ImagePrinter { GraphicsMode::Iterm2Multipart => Self::Iterm(ItermPrinter::new(ItermMode::Multipart, capabilities.tmux)), GraphicsMode::AsciiBlocks => Self::Ascii(AsciiPrinter), GraphicsMode::Raw => Self::Raw(RawPrinter), - #[cfg(feature = "sixel")] - GraphicsMode::Sixel => Self::Sixel(super::protocols::sixel::SixelPrinter::new()?), + GraphicsMode::Sixel => Self::Sixel(SixelPrinter::new()?), }; Ok(printer) } @@ -130,7 +128,6 @@ impl PrintImage for ImagePrinter { Self::Ascii(printer) => TerminalImage::Ascii(printer.register(spec)?), Self::Null => return Err(RegisterImageError::Unsupported), Self::Raw(printer) => TerminalImage::Raw(printer.register(spec)?), - #[cfg(feature = "sixel")] Self::Sixel(printer) => TerminalImage::Sixel(printer.register(spec)?), }; Ok(image) @@ -146,7 +143,6 @@ impl PrintImage for ImagePrinter { (Self::Ascii(printer), TerminalImage::Ascii(image)) => printer.print(image, options, terminal), (Self::Null, _) => Ok(()), (Self::Raw(printer), TerminalImage::Raw(image)) => printer.print(image, options, terminal), - #[cfg(feature = "sixel")] (Self::Sixel(printer), TerminalImage::Sixel(image)) => printer.print(image, options, terminal), _ => Err(PrintImageError::Unsupported), } @@ -173,7 +169,6 @@ impl fmt::Debug for ImageRegistry { ImagePrinter::Ascii(_) => "Ascii", ImagePrinter::Null => "Null", ImagePrinter::Raw(_) => "Raw", - #[cfg(feature = "sixel")] ImagePrinter::Sixel(_) => "Sixel", }; write!(f, "ImageRegistry<{inner}>") diff --git a/src/terminal/image/protocols/mod.rs b/src/terminal/image/protocols/mod.rs index f9f5dbf..522e5be 100644 --- a/src/terminal/image/protocols/mod.rs +++ b/src/terminal/image/protocols/mod.rs @@ -2,5 +2,4 @@ pub(crate) mod ascii; pub(crate) mod iterm; pub(crate) mod kitty; pub(crate) mod raw; -#[cfg(feature = "sixel")] pub(crate) mod sixel; diff --git a/src/terminal/mod.rs b/src/terminal/mod.rs index 14b12de..f241e1b 100644 --- a/src/terminal/mod.rs +++ b/src/terminal/mod.rs @@ -11,11 +11,8 @@ pub(crate) use printer::{Terminal, TerminalWrite, should_hide_cursor}; pub enum GraphicsMode { Iterm2, Iterm2Multipart, - Kitty { - mode: image::protocols::kitty::KittyMode, - }, + Kitty { mode: image::protocols::kitty::KittyMode }, AsciiBlocks, Raw, - #[cfg(feature = "sixel")] Sixel, }