Don't redraw more often than the configured frame-rate
This commit is contained in:
28
src/app.rs
28
src/app.rs
@ -207,20 +207,6 @@ impl App {
|
|||||||
|
|
||||||
let mut changes_since_last_render = true;
|
let mut changes_since_last_render = true;
|
||||||
loop {
|
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! {
|
tokio::select! {
|
||||||
e = tui.next() => {
|
e = tui.next() => {
|
||||||
if let Some(e) = e {
|
if let Some(e) = e {
|
||||||
@ -289,7 +275,19 @@ impl App {
|
|||||||
changes_since_last_render = true;
|
changes_since_last_render = true;
|
||||||
},
|
},
|
||||||
Action::Render => {
|
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) => {
|
Action::RunCommand(ref command_line) => {
|
||||||
changes_since_last_render = true;
|
changes_since_last_render = true;
|
||||||
|
Reference in New Issue
Block a user