1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use std::{error::Error, time::Duration};

use ascii_forge::prelude::*;

fn main() -> Result<(), Box<dyn Error>> {
    let mut event = Event::FocusGained;
    let mut window = Window::init()?;

    if !window.supports().keyboard() {
        window.restore()?;
        eprintln!("This game does not support this terminal.\nIf Curious, look up terminals that support the kitty keyboard protocol");
        return Err("Terminal Unsupported".into());
    }

    loop {
        window.update(Duration::ZERO)?;

        if let Some(new_event) = window.event() {
            event = new_event.clone();
        }

        render!(
            window, [
                vec2(0, 20) => "To Quit, Press Ctrl + C".red(),
                vec2(0, 0) => format!("{:#?}", event).replace('\t', "   "),
            ]
        );

        if window.key(KeyEvent::new(KeyCode::Char('c'), KeyModifiers::CONTROL)) {
            break;
        }
    }

    Ok(())
}