mod app; mod input; mod theme; mod ui; use crossterm::{ event, execute, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, }; use ratatui::{backend::CrosstermBackend, Terminal}; use std::io::stdout; fn main() -> Result<(), Box> { enable_raw_mode()?; let (width, height) = crossterm::terminal::size()?; println!("Width: {}, Height: {}", width, height); // if width < 15 || height < 15 { // disable_raw_mode()?; // println!("Your console is too small."); // return Ok(()); // } let mut stdout = stdout(); execute!(stdout, EnterAlternateScreen)?; let backend = CrosstermBackend::new(stdout); let mut terminal = Terminal::new(backend)?; let mut app = app::App::new(); let mut blink_counter = 0; loop { let blink = (blink_counter / 3) % 2 == 0; terminal.draw(|f| ui::draw(f, &app, blink))?; blink_counter += 1; let timeout = if app.show_welcome { std::time::Duration::from_millis(70) } else { std::time::Duration::from_millis(60) }; if event::poll(timeout)? { let event = event::read()?; if !input::handle_input(&mut app, event) { break; } } } disable_raw_mode()?; execute!(terminal.backend_mut(), LeaveAlternateScreen)?; Ok(()) }