-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathdemo.rs
31 lines (27 loc) · 885 Bytes
/
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
use std::path::PathBuf;
use heh::app::Application as Heh;
use heh::decoder::Encoding;
use ratatui::{
crossterm::event::{self, Event, KeyCode},
Frame,
};
fn main() {
let path = PathBuf::from("Cargo.toml");
let file = std::fs::OpenOptions::new().read(true).write(true).open(path).unwrap();
let mut heh = Heh::new(file, Encoding::Ascii, 0).unwrap();
let mut terminal = ratatui::init();
loop {
terminal
.draw(|frame: &mut Frame| {
heh.render_frame(frame, frame.area());
})
.expect("failed to draw frame");
if let Event::Key(key) = event::read().expect("failed to read event") {
if key.code == KeyCode::Char('q') {
break;
}
heh.handle_input(&ratatui::crossterm::event::Event::Key(key)).unwrap();
}
}
ratatui::restore();
}