mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-07-23 21:55:11 +02:00
Refactoring - moved canvas into its own struct... time to do some more fun optimization.
This commit is contained in:
parent
41d56d8a9b
commit
e0115624a9
1776
src/canvas.rs
1776
src/canvas.rs
File diff suppressed because it is too large
Load Diff
23
src/main.rs
23
src/main.rs
@ -230,8 +230,9 @@ fn main() -> error::Result<()> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut painter = canvas::Painter::default();
|
||||||
loop {
|
loop {
|
||||||
// TODO: [OPT] this should not block... let's properly use tick rates and non-blocking, okay?
|
// TODO: [OPT] this should not block...
|
||||||
if let Ok(recv) = rx.recv_timeout(Duration::from_millis(TICK_RATE_IN_MILLISECONDS)) {
|
if let Ok(recv) = rx.recv_timeout(Duration::from_millis(TICK_RATE_IN_MILLISECONDS)) {
|
||||||
match recv {
|
match recv {
|
||||||
Event::KeyInput(event) => {
|
Event::KeyInput(event) => {
|
||||||
@ -372,18 +373,26 @@ fn main() -> error::Result<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw!
|
try_drawing(&mut terminal, &mut app, &mut painter)?;
|
||||||
if let Err(err) = canvas::draw_data(&mut terminal, &mut app) {
|
|
||||||
cleanup_terminal(&mut terminal)?;
|
|
||||||
error!("{}", err);
|
|
||||||
return Err(err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup_terminal(&mut terminal)?;
|
cleanup_terminal(&mut terminal)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn try_drawing(
|
||||||
|
terminal: &mut tui::terminal::Terminal<tui::backend::CrosstermBackend<std::io::Stdout>>,
|
||||||
|
app: &mut app::App, painter: &mut canvas::Painter,
|
||||||
|
) -> error::Result<()> {
|
||||||
|
if let Err(err) = painter.draw_data(terminal, app) {
|
||||||
|
cleanup_terminal(terminal)?;
|
||||||
|
error!("{}", err);
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn cleanup_terminal(
|
fn cleanup_terminal(
|
||||||
terminal: &mut tui::terminal::Terminal<tui::backend::CrosstermBackend<std::io::Stdout>>,
|
terminal: &mut tui::terminal::Terminal<tui::backend::CrosstermBackend<std::io::Stdout>>,
|
||||||
) -> error::Result<()> {
|
) -> error::Result<()> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user