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
use crate::utils;
/// Configuration struct to customize printing behaviour.
pub struct Config {
/// Enable true transparency instead of checkerboard background.
/// Available only for the block printer. Defaults to false.
pub transparent: bool,
/// Make the x and y offset be relative to the top left terminal corner.
/// If false, the y offset is relative to the cursor's position.
/// Defaults to true.
pub absolute_offset: bool,
/// X offset. Defaults to 0.
pub x: u16,
/// Y offset. Can be negative only when `absolute_offset` is `false`. Defaults to 0.
pub y: i16,
/// Take a note of cursor position before printing and restore it when finished.
/// Defaults to false.
pub restore_cursor: bool,
/// Optional image width. Defaults to None.
pub width: Option<u32>,
/// Optional image height. Defaults to None.
pub height: Option<u32>,
/// Use truecolor if the terminal supports it. Defaults to true.
pub truecolor: bool,
/// Use Kitty protocol if the terminal supports it. Defaults to true.
pub use_kitty: bool,
/// Use iTerm protocol if the terminal supports it. Defaults to true.
pub use_iterm: bool,
/// Use Sixel protocol if the terminal supports it. Defaults to true.
#[cfg(feature = "sixel")]
pub use_sixel: bool,
}
impl std::default::Default for Config {
fn default() -> Self {
Self {
transparent: false,
absolute_offset: true,
x: 0,
y: 0,
restore_cursor: false,
width: None,
height: None,
truecolor: utils::truecolor_available(),
use_kitty: true,
use_iterm: true,
#[cfg(feature = "sixel")]
use_sixel: true,
}
}
}