-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathratatui.rs
More file actions
39 lines (32 loc) · 1.07 KB
/
Copy pathratatui.rs
File metadata and controls
39 lines (32 loc) · 1.07 KB
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::time::Duration;
use crossterm::event;
use ratatui::{
layout::{Alignment, Constraint, Direction, Layout},
widgets::Paragraph,
};
use rattles::presets::prelude as presets;
fn main() -> Result<(), Box<dyn std::error::Error>> {
ratatui::run(|terminal| {
loop {
terminal.draw(|frame| {
let area = frame.area();
let layout = Layout::default()
.direction(Direction::Vertical)
.constraints([
Constraint::Fill(1),
Constraint::Length(1),
Constraint::Fill(1),
])
.split(area);
let spinner =
Paragraph::new(presets::dots().current_frame()).alignment(Alignment::Center);
frame.render_widget(spinner, layout[1]);
})?;
if event::poll(Duration::from_millis(10))? {
break;
}
std::thread::sleep(std::time::Duration::from_millis(33));
}
Ok(())
})
}