use crate::buffer::Cell;
use crate::geometry::{Position, Size};
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum ClearType {
All,
AfterCursor,
BeforeCursor,
CurrentLine,
UntilNewLine,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct WindowSize {
pub columns_rows: Size,
pub pixels: Size,
}
pub trait Backend {
type Error: core::error::Error;
fn draw<'a, I>(&mut self, content: I) -> Result<(), Self::Error>
where
I: Iterator<Item = (u16, u16, &'a Cell)>;
fn append_lines(&mut self, _n: u16) -> Result<(), Self::Error> {
Ok(())
}
fn hide_cursor(&mut self) -> Result<(), Self::Error>;
fn show_cursor(&mut self) -> Result<(), Self::Error>;
fn get_cursor_position(&mut self) -> Result<Position, Self::Error>;
fn set_cursor_position<P: Into<Position>>(&mut self, position: P) -> Result<(), Self::Error>;
fn clear(&mut self) -> Result<(), Self::Error>;
fn clear_region(&mut self, clear_type: ClearType) -> Result<(), Self::Error>;
fn size(&self) -> Result<Size, Self::Error>;
fn window_size(&mut self) -> Result<WindowSize, Self::Error>;
fn flush(&mut self) -> Result<(), Self::Error>;
#[cfg(feature = "scrolling-regions")]
fn scroll_region_up(
&mut self,
region: core::ops::Range<u16>,
line_count: u16,
) -> Result<(), Self::Error>;
#[cfg(feature = "scrolling-regions")]
fn scroll_region_down(
&mut self,
region: core::ops::Range<u16>,
line_count: u16,
) -> Result<(), Self::Error>;
}