Don't redraw more often than the configured frame-rate

This commit is contained in:
2023-11-04 14:58:08 +01:00
parent 58ab62d7d3
commit b609c26b2c

View File

@ -207,20 +207,6 @@ impl App {
let mut changes_since_last_render = true;
loop {
if changes_since_last_render {
tui.draw(|f| {
for component in self.components.iter_mut() {
let r = component.draw(f, f.size(), &self.buffers);
if let Err(e) = r {
action_tx
.send(Action::Error(format!("Failed to draw: {:?}", e)))
.unwrap();
}
}
})?;
changes_since_last_render = false;
}
tokio::select! {
e = tui.next() => {
if let Some(e) = e {
@ -289,7 +275,19 @@ impl App {
changes_since_last_render = true;
},
Action::Render => {
// Merely used as a way to signify it's time to render any pending update
if changes_since_last_render {
tui.draw(|f| {
for component in self.components.iter_mut() {
let r = component.draw(f, f.size(), &self.buffers);
if let Err(e) = r {
action_tx
.send(Action::Error(format!("Failed to draw: {:?}", e)))
.unwrap();
}
}
})?;
changes_since_last_render = false;
}
},
Action::RunCommand(ref command_line) => {
changes_since_last_render = true;