use crate::error::Result;
use crate::geometry::Size;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum ColorSupport {
NoColor,
Basic16,
Extended256,
TrueColor,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct TerminalCapabilities {
pub color: ColorSupport,
pub unicode: bool,
pub synchronized_output: bool,
pub kitty_keyboard: bool,
pub mouse: bool,
pub bracketed_paste: bool,
pub focus_events: bool,
pub hyperlinks: bool,
pub sixel: bool,
}
impl Default for TerminalCapabilities {
fn default() -> Self {
Self {
color: ColorSupport::TrueColor,
unicode: true,
synchronized_output: false,
kitty_keyboard: false,
mouse: true,
bracketed_paste: true,
focus_events: true,
hyperlinks: true,
sixel: false,
}
}
}
pub trait Terminal: Send {
fn size(&self) -> Result<Size>;
fn capabilities(&self) -> &TerminalCapabilities;
fn enter_raw_mode(&mut self) -> Result<()>;
fn exit_raw_mode(&mut self) -> Result<()>;
fn write_raw(&mut self, data: &[u8]) -> Result<()>;
fn flush(&mut self) -> Result<()>;
fn enable_mouse(&mut self) -> Result<()>;
fn disable_mouse(&mut self) -> Result<()>;
}