aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-05 03:38:08 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-05 03:38:08 -0500
commitd1200faeea5dd513f6b02958f84669f6dde925fe (patch)
tree97be42181b1769075156f9024748bd20986fa89c
parent8fae72f67707924118f965b9e14b5838e41cc3ad (diff)
downloadttyrec-bin-d1200faeea5dd513f6b02958f84669f6dde925fe.tar.gz
ttyrec-bin-d1200faeea5dd513f6b02958f84669f6dde925fe.zip
also allow setting the initial speed on the command line
-rw-r--r--src/bin/ttyplay/main.rs7
-rw-r--r--src/bin/ttyplay/timer.rs3
2 files changed, 9 insertions, 1 deletions
diff --git a/src/bin/ttyplay/main.rs b/src/bin/ttyplay/main.rs
index 699d329..d05ba5d 100644
--- a/src/bin/ttyplay/main.rs
+++ b/src/bin/ttyplay/main.rs
@@ -21,6 +21,9 @@ struct Opt {
#[structopt(short, long)]
paused: bool,
+
+ #[structopt(short, long, default_value = "4")]
+ speed: u32,
}
async fn async_main(opt: Opt) -> anyhow::Result<()> {
@@ -28,8 +31,11 @@ async fn async_main(opt: Opt) -> anyhow::Result<()> {
file,
clamp,
paused,
+ speed,
} = opt;
+ let speed = speed.clamp(0, 8);
+
let fh = async_std::fs::File::open(file).await?;
let mut input = textmode::Input::new().await?;
@@ -52,6 +58,7 @@ async fn async_main(opt: Opt) -> anyhow::Result<()> {
frame_data.clone(),
timer_r,
paused,
+ speed,
);
event::handle_events(event_r, timer_w.clone(), output, paused).await?;
diff --git a/src/bin/ttyplay/timer.rs b/src/bin/ttyplay/timer.rs
index db85001..f5cf2dc 100644
--- a/src/bin/ttyplay/timer.rs
+++ b/src/bin/ttyplay/timer.rs
@@ -7,6 +7,7 @@ pub fn spawn_task(
>,
timer_r: async_std::channel::Receiver<crate::event::TimerAction>,
pause_at_start: bool,
+ speed: u32,
) -> async_std::task::JoinHandle<()> {
async_std::task::spawn(async move {
let mut idx = 0;
@@ -17,7 +18,7 @@ pub fn spawn_task(
None
};
let mut force_update_time = false;
- let mut playback_ratio = 16;
+ let mut playback_ratio = 2_u32.pow(speed);
loop {
enum Res {
Wait(Option<vt100::Screen>),