rustom 0.1.0

A library for building rich, stateful terminal user interfaces and dashboards.
Documentation
//! The `Backend` trait abstracts over the terminal driver used to actually
//! paint cells to the screen, so `Terminal` can stay backend agnostic.

mod crossterm;
pub use crossterm::CrosstermBackend;

use std::io;

use crate::buffer::Cell;
use crate::layout::Rect;

/// Low level terminal operations that a `Terminal` needs from its driver.
pub trait Backend {
    /// Draws the given cells at their absolute `(x, y)` positions. Only
    /// cells that changed since the last frame are passed in.
    fn draw<'a, I>(&mut self, content: I) -> io::Result<()>
    where
        I: Iterator<Item = (u16, u16, &'a Cell)>;

    fn hide_cursor(&mut self) -> io::Result<()>;
    fn show_cursor(&mut self) -> io::Result<()>;
    fn set_cursor_position(&mut self, x: u16, y: u16) -> io::Result<()>;
    fn clear(&mut self) -> io::Result<()>;
    fn size(&self) -> io::Result<Rect>;
    fn flush(&mut self) -> io::Result<()>;
}