tuigui 0.23.0

An easy-to-use, highly extensible, and speedy TUI library.
Documentation
use std::io;

use crate::{ Size, Position };

/// Clear type for clearing the terminal
pub enum ClearType {
    /// All cells
    All,
    /// All cells + history
    Purge,
    /// All cells at the cursor row
    CurrentLine,
    /// All cells from the cursor down
    FromCursorDown,
    /// All cells from the cursor up
    FromCursorUp,
    /// All cells from the cursor position until the new line
    UntilNewLine,
}

/// Trait for backends, implementing this trait on a datatype
/// means you can use it as a backend for the context!
/// backends are responsible for everything regarding the terminal.
/// This means you could actually implement a backend that talks to
/// a GUI written in GTK, QT, Iced, or anything else!
pub trait Backend<T> {
    /// Flush queued changes
    fn flush(&mut self) -> Result<(), io::Error>;

    /// Get the size of the terminal in rows and columns
    fn terminal_size(&self) -> Result<Size, io::Error>;

    /// Set the cursor position in the terminal
    fn set_cursor_pos(&mut self, position: Position) -> Result<(), io::Error>;

    /// Enter/leave alternate screen
    fn alt_screen(&mut self, enable: bool) -> Result<(), io::Error>;

    /// Enable/disable raw mode
    fn raw_mode(&mut self, enable: bool) -> Result<(), io::Error>;

    /// Enable/disable mouse capture
    fn capture_mouse(&mut self, enable: bool) -> Result<(), io::Error>;

    /// Clear parts of or the entire terminal
    fn clear(&mut self, clear_type: ClearType) -> Result<(), io::Error>;

    /// Show/hide the cursor
    fn show_cursor(&mut self, enable: bool) -> Result<(), io::Error>;

    /// Begin synchronized update
    fn begin_sync_update(&mut self) -> Result<(), io::Error>;

    /// End synchronized update
    fn end_sync_update(&mut self) -> Result<(), io::Error>;

    /// Print to the screen
    fn print(&mut self, print: T) -> Result<(), io::Error>;

    /// Get the cursor's position
    fn cursor_position(&self) -> Result<Position, io::Error>;
}