1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
//!
/// Pixel blitting implementations, informative only.
///
/// This is returned by [`Nc.check_pixel_support`].
///
/// [`Nc.check_pixel_support`]: crate::Nc#method.check_pixel_support
#[repr(u32)]
#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NcPixelImpl {
/// No pixel support.
None = c_api::NCPIXEL_NONE,
/// Sixel.
Sixel = c_api::NCPIXEL_SIXEL,
/// Linux framebuffer.
LinuxFb = c_api::NCPIXEL_LINUXFB,
/// iTerm2.
Iterm2 = c_api::NCPIXEL_ITERM2,
/// Kitty prior to C=1 and animation.
KittyStatic = c_api::NCPIXEL_KITTY_STATIC,
/// Kitty with animation but not reflexive composition.
KittyAnimated = c_api::NCPIXEL_KITTY_ANIMATED,
/// Kitty with reflexive composition.
KittySelfRef = c_api::NCPIXEL_KITTY_SELFREF,
}
mod core_impls {
use super::{c_api::*, NcPixelImpl};
use core::fmt;
impl Default for NcPixelImpl {
fn default() -> Self {
Self::None
}
}
impl fmt::Display for NcPixelImpl {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use NcPixelImpl::*;
write!(
f,
"{}",
match self {
NcPixelImpl::None => "None",
Sixel => "Sixel",
LinuxFb => "LinuxFb",
Iterm2 => "Iterm2",
KittyStatic => "KittyStatic",
KittyAnimated => "KittyAnimated",
KittySelfRef => "KittySelfRef",
}
)
}
}
impl From<NcPixelImpl_u32> for NcPixelImpl {
fn from(alpha: NcPixelImpl_u32) -> Self {
use NcPixelImpl::*;
match alpha {
NCPIXEL_NONE => NcPixelImpl::None,
NCPIXEL_SIXEL => Sixel,
NCPIXEL_LINUXFB => LinuxFb,
NCPIXEL_ITERM2 => Iterm2,
NCPIXEL_KITTY_STATIC => KittyStatic,
NCPIXEL_KITTY_ANIMATED => KittyAnimated,
NCPIXEL_KITTY_SELFREF => KittySelfRef,
_ => Self::default(),
}
}
}
impl From<NcPixelImpl> for NcPixelImpl_u32 {
fn from(alpha: NcPixelImpl) -> Self {
use NcPixelImpl::*;
match alpha {
NcPixelImpl::None => NCPIXEL_NONE,
Sixel => NCPIXEL_SIXEL,
LinuxFb => NCPIXEL_LINUXFB,
Iterm2 => NCPIXEL_ITERM2,
KittyStatic => NCPIXEL_KITTY_STATIC,
KittyAnimated => NCPIXEL_KITTY_ANIMATED,
KittySelfRef => NCPIXEL_KITTY_SELFREF,
}
}
}
}
pub(crate) mod c_api {
use crate::c_api::ffi;
/// Pixel blitting implementations, informative only.
///
/// It's recommended to use [`NcPixelImpl`][crate::NcPixelImpl] instead.
///
/// This is returned by [`notcurses_check_pixel_support`]
///
/// # Associated `c_api` constants
///
/// - [`NCPIXEL_NONE`]
/// - [`NCPIXEL_SIXEL`]
/// - [`NCPIXEL_LINUXFB`]
/// - [`NCPIXEL_ITERM2`]
/// - [`NCPIXEL_KITTY_STATIC`]
/// - [`NCPIXEL_KITTY_ANIMATED`]
/// - [`NCPIXEL_KITTY_SELFREF`]
///
/// [`notcurses_check_pixel_support`]: crate::c_api::notcurses::check_pixel_support
pub type NcPixelImpl_u32 = ffi::ncpixelimpl_e;
/// [`NcPixelImpl_u32`] No pixel support.
pub const NCPIXEL_NONE: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_NONE;
/// [`NcPixelImpl_u32`] Sixel.
pub const NCPIXEL_SIXEL: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_SIXEL;
/// [`NcPixelImpl_u32`] Linux framebuffer.
pub const NCPIXEL_LINUXFB: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_LINUXFB;
/// [`NcPixelImpl_u32`] iTerm2.
pub const NCPIXEL_ITERM2: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_ITERM2;
/// [`NcPixelImpl_u32`] Kitty prior to C=1 and animation.
pub const NCPIXEL_KITTY_STATIC: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_KITTY_STATIC;
/// [`NcPixelImpl_u32`] Kitty with animation but not reflexive composition.
pub const NCPIXEL_KITTY_ANIMATED: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_KITTY_ANIMATED;
/// [`NcPixelImpl_u32`] Kitty with reflexive composition.
pub const NCPIXEL_KITTY_SELFREF: NcPixelImpl_u32 = ffi::ncpixelimpl_e_NCPIXEL_KITTY_SELFREF;
}