-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdemo.rs
39 lines (33 loc) · 1.14 KB
/
demo.rs
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
36
37
38
39
use std::{io::stdout, thread::sleep, time::Duration};
use anyhow::Result;
use crossterm::{
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
ExecutableCommand,
};
use ratatui::prelude::*;
use ratatui_splash_screen::{SplashConfig, SplashScreen};
static SPLASH_CONFIG: SplashConfig = SplashConfig {
image_data: include_bytes!("../assets/splash.png"),
sha256sum: Some("abc7e993ae85580df6a1349e89aa57d7d39cecdfe3cd5cc95f65b730aafab2cb"),
render_steps: 12,
use_colors: true,
};
fn main() -> Result<()> {
stdout().execute(EnterAlternateScreen)?;
enable_raw_mode()?;
let backend = CrosstermBackend::new(stdout());
let mut terminal = Terminal::new(backend)?;
terminal.clear()?;
let mut splash_screen = SplashScreen::new(SPLASH_CONFIG)?;
while !splash_screen.is_rendered() {
terminal.draw(|frame| {
frame.render_widget(&mut splash_screen, frame.size());
})?;
sleep(Duration::from_millis(100));
}
sleep(Duration::from_secs(1));
terminal.clear()?;
stdout().execute(LeaveAlternateScreen)?;
disable_raw_mode()?;
Ok(())
}