Fix another source of flickering

When you have many keystrokes in the `stdin` (pushing long keys), we are
saying to `termion` to print many things. Throttling this.
This commit is contained in:
Ferran Basora 2020-07-10 09:43:33 +00:00
parent a36d30594c
commit 10eff07d16
2 changed files with 4 additions and 2 deletions

2
Cargo.lock generated
View File

@ -141,7 +141,7 @@ dependencies = [
[[package]] [[package]]
name = "thumbs" name = "thumbs"
version = "0.4.1" version = "0.4.2"
dependencies = [ dependencies = [
"base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -238,10 +238,12 @@ impl<'a> View<'a> {
} }
Err(err) => panic!(err), Err(err) => panic!(err),
} }
stdin.keys().for_each(|_| { /* Skip the rest of stdin buffer */ })
} }
_ => { _ => {
// Nothing in the buffer. Wait for a bit... // Nothing in the buffer. Wait for a bit...
std::thread::sleep(std::time::Duration::from_millis(100)); std::thread::sleep(std::time::Duration::from_millis(50));
continue; // don't render again if nothing new to show continue; // don't render again if nothing new to show
} }
} }