andiskaz 0.2.0

A convenience library for writing games and other apps in TUI
Documentation
use andiskaz::{
    emergency_restore,
    error::Error,
    terminal::Terminal,
    tstring,
    ui::info::InfoDialog,
};
use std::{panic, process::exit};

/// Asynchronous main of a tokio project.
#[tokio::main]
async fn main() {
    // Sets panic hook so we can see the panic even if terminal was being used
    // in raw mode.
    panic::set_hook(Box::new(|info| {
        let _ = emergency_restore();
        eprintln!("{}", info);
    }));

    // Creates a terminal with default settings and runs it.
    let result = Terminal::run(term_main).await;
    // If error, prints it out and exits with bad code.
    if let Ok(Err(error)) | Err(error) = result {
        eprintln!("{}", error);
        exit(-1);
    }
}

/// The terminal main function.
async fn term_main(mut term: Terminal) -> Result<(), Error> {
    InfoDialog::new(tstring!["Hello"], tstring!["This is a hello message"])
        .run(&mut term)
        .await?;

    Ok(())
}