diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2021-11-23 13:02:44 +0100 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2021-11-23 13:02:44 +0100 |
commit | fc6cec72aead59c1d45044e8945c5b8119eab823 (patch) | |
tree | 9b40f3ce1f8e709ee18fdf0298554185f83fe66d /src/vtcol.rs | |
parent | 84a552f3265d82e9fa553e9ddd3597a56739cbee (diff) | |
download | vtcol-fc6cec72aead59c1d45044e8945c5b8119eab823.tar.gz |
optionally clear after each fade step
Diffstat (limited to 'src/vtcol.rs')
-rw-r--r-- | src/vtcol.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/vtcol.rs b/src/vtcol.rs index 3694753..e3ab5f2 100644 --- a/src/vtcol.rs +++ b/src/vtcol.rs @@ -34,7 +34,7 @@ enum Job /** Toggle between two schemes. */ Toggle(Scheme, Scheme), /** Fade from current scheme to another. */ - Fade(Option<Scheme>, Scheme, Duration, u8), + Fade(Option<Scheme>, Scheme, Duration, u8, bool), } impl<'a> Job @@ -126,6 +126,13 @@ impl<'a> Job .takes_value(true), ) .arg( + Arg::with_name("clear") + .short("c") + .long("clear") + .help("clear terminal on each fade step") + .takes_value(false), + ) + .arg( Arg::with_name("frequency") .value_name("HZ") .short("h") @@ -202,6 +209,7 @@ impl<'a> Job } else { DEFAULT_FADE_UPDATE_HZ }; + let clear = subm.is_present("clear"); let dur = Duration::from_millis(dur); match (subm.value_of("from"), subm.value_of("to")) { @@ -213,6 +221,7 @@ impl<'a> Job Scheme::from(to), dur, hz, + clear, )), } }, @@ -280,7 +289,8 @@ impl<'a> Job Self::Set(scm) => Self::set_scheme(scm)?, Self::Get => Self::get_scheme()?, Self::Toggle(one, two) => Self::toggle_scheme(one, two)?, - Self::Fade(from, to, ms, hz) => Self::fade(from, to, ms, hz)?, + Self::Fade(from, to, ms, hz, clear) => + Self::fade(from, to, ms, hz, clear)?, } Ok(()) @@ -335,6 +345,7 @@ impl<'a> Job to: Scheme, dur: Duration, hz: u8, + clear: bool, ) -> Result<()> { let fd = Console::current()?; @@ -347,7 +358,7 @@ impl<'a> Job }; let to = Palette::try_from(&to)?; - let fade = Fade::new(from, to, dur, hz); + let fade = Fade::new(from, to, dur, hz, clear); fade.commence(&fd)?; Ok(()) |