summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrabite0 <rabite@posteo.de>2019-07-08 13:20:25 +0200
committerGitHub <noreply@github.com>2019-07-08 13:20:25 +0200
commit19be163b3cb5f1d806ff9fb3aae745ac409a41a9 (patch)
tree2cad09783401125f7005f2dcd7c9600acf1264a2
parent072b39b3cfeac109f8bb0fff747c6dc50d747942 (diff)
parent9698167285990798e8b0f9522deb27261112ef26 (diff)
Merge pull request #60 from petrusboniatus/master
Added configurable refresh rate
-rw-r--r--src/config.rs8
-rw-r--r--src/widget.rs9
2 files changed, 15 insertions, 2 deletions
diff --git a/src/config.rs b/src/config.rs
index 21d8404..1095f80 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -79,6 +79,7 @@ fn infuse_argv_config(mut config: Config) -> Config {
#[derive(Debug, Clone)]
pub struct Config {
pub animation: bool,
+ pub animation_refresh_frequency: usize,
pub show_hidden: bool,
pub select_cmd: String,
pub cd_cmd: String,
@@ -101,6 +102,7 @@ impl Config {
pub fn default() -> Config {
Config {
animation: true,
+ animation_refresh_frequency: 60,
show_hidden: false,
select_cmd: "find -type f | fzf -m".to_string(),
cd_cmd: "find -type d | fzf".to_string(),
@@ -126,6 +128,12 @@ impl Config {
match Config::prep_line(line) {
Ok(("animation", "on")) => { config.animation = true; },
Ok(("animation", "off")) => { config.animation = false; },
+ Ok(("animation_refresh_frequency", frequency)) => {
+ match frequency.parse::<usize>() {
+ Ok(parsed_freq) => config.animation_refresh_frequency = parsed_freq,
+ _ => HError::config_error::<Config>(line.to_string()).log()
+ }
+ }
Ok(("show_hidden", "on")) => { config.show_hidden = true; },
Ok(("show_hidden", "off")) => { config.show_hidden = false; },
Ok(("icons", "on")) => config.icons = true,
diff --git a/src/widget.rs b/src/widget.rs
index 8e2019d..8002df4 100644
--- a/src/widget.rs
+++ b/src/widget.rs
@@ -406,7 +406,12 @@ pub trait Widget {
let xsize = coords.xsize();
let ysize = coords.ysize();
let clear = self.get_core()?.get_clearlist()?;
- let pause = std::time::Duration::from_millis(5);
+
+ let animation_hz = self.get_core()?.config().animation_refresh_frequency as u64;
+ let pause_millis = 1000/animation_hz;
+ const ANIMATION_DURATION_MILLIS: u64 = 64;
+ let number_of_frames= (ANIMATION_DURATION_MILLIS/pause_millis) as u16;
+ let pause = std::time::Duration::from_millis(pause_millis);
if let Some(ref animator) = animator {
if animator.is_stale()? {
@@ -416,7 +421,7 @@ pub trait Widget {
self.get_core()?.write_to_screen(&clear).log();
- for i in (0..10).rev() {
+ for i in (0..number_of_frames).rev() {
if let Some(ref animator) = animator {
if animator.is_stale()? {
self.set_coordinates(&coords).log();