blob: 58eaef2834abdd16429f0102410cb139af4042df (
plain)
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
40
41
42
43
44
45
46
47
48
49
50
|
use termion::event::{Event, Key};
use tui::layout::Rect;
use crate::context::JoshutoContext;
use crate::ui::widgets::TuiWorker;
use crate::ui::TuiBackend;
use crate::util::event::JoshutoEvent;
use crate::util::input_process;
pub struct TuiWorkerView {}
impl TuiWorkerView {
pub fn new() -> Self {
Self {}
}
pub fn display(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) {
context.flush_event();
let terminal = backend.terminal_mut();
loop {
let _ = terminal.draw(|frame| {
let f_size: Rect = frame.size();
if f_size.height == 0 {
return;
}
{
let view = TuiWorker::new(&context);
frame.render_widget(view, f_size);
}
});
if let Ok(event) = context.poll_event() {
match event {
JoshutoEvent::Termion(event) => {
match event {
Event::Key(Key::Esc) => {
break;
}
_ => {}
}
context.flush_event();
}
event => input_process::process_noninteractive(event, context),
};
}
}
}
}
|