diff --git a/src/config.rs b/src/config.rs index 5e24123..f89e4bc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -71,6 +71,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, @@ -92,6 +93,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(), @@ -116,6 +118,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::() { + Ok(parsed_freq) => config.animation_refresh_frequency = parsed_freq, + _ => HError::config_error::(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();