2024-07-09 20:08:58 +02:00
|
|
|
use std::io;
|
2024-07-09 13:41:25 +02:00
|
|
|
|
2024-07-09 20:08:58 +02:00
|
|
|
use libpt::cli::clap::Parser;
|
|
|
|
use ratatui::backend::CrosstermBackend;
|
|
|
|
use ratatui::crossterm::event::{DisableMouseCapture, EnableMouseCapture};
|
|
|
|
use ratatui::crossterm::execute;
|
|
|
|
use ratatui::crossterm::terminal::{
|
|
|
|
disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen,
|
2024-07-09 11:58:12 +02:00
|
|
|
};
|
2024-07-09 20:08:58 +02:00
|
|
|
use ratatui::Terminal;
|
|
|
|
|
|
|
|
use self::clock::Clock;
|
|
|
|
|
|
|
|
mod clock;
|
2024-07-09 11:58:12 +02:00
|
|
|
|
2024-07-09 20:08:58 +02:00
|
|
|
fn main() -> anyhow::Result<()> {
|
2024-07-09 11:58:12 +02:00
|
|
|
// setup terminal
|
|
|
|
enable_raw_mode()?;
|
|
|
|
let mut stdout = io::stdout();
|
|
|
|
execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;
|
|
|
|
let backend = CrosstermBackend::new(stdout);
|
|
|
|
let mut terminal = Terminal::new(backend)?;
|
|
|
|
|
2024-07-09 20:08:58 +02:00
|
|
|
let clock = Clock::parse();
|
|
|
|
clock.run(&mut terminal)?;
|
2024-07-09 11:58:12 +02:00
|
|
|
|
|
|
|
// restore terminal
|
|
|
|
disable_raw_mode()?;
|
|
|
|
execute!(
|
|
|
|
terminal.backend_mut(),
|
|
|
|
LeaveAlternateScreen,
|
|
|
|
DisableMouseCapture
|
|
|
|
)?;
|
|
|
|
terminal.show_cursor()?;
|
|
|
|
|
|
|
|
Ok(())
|
2024-03-04 15:14:28 +01:00
|
|
|
}
|