use std::fmt;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u8)]
#[derive(Default)]
pub enum ImageFormat {
Rgb = 24,
#[default]
Rgba = 32,
Png = 100,
}
impl fmt::Display for ImageFormat {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", *self as u8)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum TransmissionMedium {
#[default]
Direct,
File,
TempFile,
SharedMemory,
}
impl fmt::Display for TransmissionMedium {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let c = match self {
Self::Direct => 'd',
Self::File => 'f',
Self::TempFile => 't',
Self::SharedMemory => 's',
};
write!(f, "{c}")
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum Action {
Query,
Transmit,
#[default]
TransmitAndDisplay,
Place,
Delete,
Frame,
AnimationControl,
ComposeFrame,
}
impl fmt::Display for Action {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
Self::Query => "q",
Self::Transmit => "t",
Self::TransmitAndDisplay => "T",
Self::Place => "p",
Self::Delete => "d",
Self::Frame => "f",
Self::AnimationControl => "a",
Self::ComposeFrame => "c",
};
write!(f, "{s}")
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum DeleteTarget {
All,
AllWithFree,
ById { free_data: bool },
ByNumber { free_data: bool },
AtCursor { free_data: bool },
Frames { free_data: bool },
AtCell { free_data: bool },
AtCellWithZIndex { free_data: bool },
ByIdRange { free_data: bool },
ByColumn { free_data: bool },
ByRow { free_data: bool },
ByZIndex { free_data: bool },
}
impl DeleteTarget {
pub fn code(&self) -> char {
match self {
Self::All => 'a',
Self::AllWithFree => 'A',
Self::ById { free_data: false } => 'i',
Self::ById { free_data: true } => 'I',
Self::ByNumber { free_data: false } => 'n',
Self::ByNumber { free_data: true } => 'N',
Self::AtCursor { free_data: false } => 'c',
Self::AtCursor { free_data: true } => 'C',
Self::Frames { free_data: false } => 'f',
Self::Frames { free_data: true } => 'F',
Self::AtCell { free_data: false } => 'p',
Self::AtCell { free_data: true } => 'P',
Self::AtCellWithZIndex { free_data: false } => 'q',
Self::AtCellWithZIndex { free_data: true } => 'Q',
Self::ByIdRange { free_data: false } => 'r',
Self::ByIdRange { free_data: true } => 'R',
Self::ByColumn { free_data: false } => 'x',
Self::ByColumn { free_data: true } => 'X',
Self::ByRow { free_data: false } => 'y',
Self::ByRow { free_data: true } => 'Y',
Self::ByZIndex { free_data: false } => 'z',
Self::ByZIndex { free_data: true } => 'Z',
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum AnimationControl {
Stop,
Loading,
Run,
}
impl fmt::Display for AnimationControl {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let n = match self {
Self::Stop => 1,
Self::Loading => 2,
Self::Run => 3,
};
write!(f, "{n}")
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum CompositionMode {
#[default]
AlphaBlend,
Replace,
}
impl fmt::Display for CompositionMode {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let n = match self {
Self::AlphaBlend => 0,
Self::Replace => 1,
};
write!(f, "{n}")
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct FrameComposition {
pub source_frame: u32,
pub dest_frame: u32,
pub width: Option<u32>,
pub height: Option<u32>,
pub source_x: Option<u32>,
pub source_y: Option<u32>,
pub dest_x: Option<u32>,
pub dest_y: Option<u32>,
pub mode: CompositionMode,
}
impl Default for FrameComposition {
fn default() -> Self {
Self {
source_frame: 1,
dest_frame: 1,
width: None,
height: None,
source_x: None,
source_y: None,
dest_x: None,
dest_y: None,
mode: CompositionMode::AlphaBlend,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct UnicodePlaceholder {
pub columns: u16,
pub rows: u16,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Compression {
Zlib,
}
impl fmt::Display for Compression {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
Self::Zlib => "z",
};
write!(f, "{s}")
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
pub enum CursorPolicy {
#[default]
Default,
NoMove,
}
impl fmt::Display for CursorPolicy {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let n = match self {
Self::Default => 0,
Self::NoMove => 1,
};
write!(f, "{n}")
}
}