glyph_ui 0.1.0

TUI library utilizing the Elm architecture
Documentation
use std::fmt;

use crossterm as ct;
use euclid::Point2D;

use crate::unit::Cell;

#[derive(Clone)]
pub(crate) enum Command {
    MoveTo(Point2D<u16, Cell>),
    Print(String),
    ShowCursor,
    HideCursor,
}

impl ct::Command for Command {
    fn write_ansi(&self, f: &mut impl fmt::Write) -> fmt::Result {
        match self {
            Self::MoveTo(point) => {
                ct::cursor::MoveTo(point.x, point.y).write_ansi(f)
            }
            Self::Print(x) => ct::style::Print(x).write_ansi(f),
            Self::ShowCursor => ct::cursor::Show.write_ansi(f),
            Self::HideCursor => ct::cursor::Hide.write_ansi(f),
        }
    }
}

#[derive(Default)]
pub(crate) struct CommandBuf {
    pub changes_cursor: bool,
    pub cmds: Vec<Command>,
}