aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-04 23:15:43 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-04 23:15:43 -0500
commit3b77a5efde1e359c1b04fafe626f4a49c6ffcd09 (patch)
tree7470b5d18adef74271a2dd85d8a4deed4ed035a1
parentde02603105db0b5bc0f21f17f5a74976aa8dbf2c (diff)
downloadttyrec-bin-3b77a5efde1e359c1b04fafe626f4a49c6ffcd09.tar.gz
ttyrec-bin-3b77a5efde1e359c1b04fafe626f4a49c6ffcd09.zip
fix moving forward and backward
-rw-r--r--src/bin/ttyplay/main.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/bin/ttyplay/main.rs b/src/bin/ttyplay/main.rs
index 6f858fd..e24d16e 100644
--- a/src/bin/ttyplay/main.rs
+++ b/src/bin/ttyplay/main.rs
@@ -82,7 +82,12 @@ fn spawn_timer_task(
frames.lock_arc().await.get(idx).unwrap().clone();
if force_update_time {
let now = std::time::Instant::now();
- start_time = now - frame.delay();
+ start_time = now - frame.delay()
+ // give a bit of extra time before moving to the
+ // next frame, otherwise backing up behind two
+ // frames that are extremely close together
+ // doesn't work
+ + std::time::Duration::from_millis(200);
if paused_time.take().is_some() {
paused_time = Some(now);
}
@@ -136,17 +141,13 @@ fn spawn_timer_task(
idx = frames.lock_arc().await.count() - 1;
force_update_time = true;
}
+ // force_update_time will immediately transition to the
+ // next frame and do idx += 1 on its own
TimerAction::NextFrame => {
- let max = frames.lock_arc().await.count() - 1;
- if idx < max {
- idx += 1;
- }
force_update_time = true;
}
TimerAction::PreviousFrame => {
- if idx > 0 {
- idx -= 1;
- }
+ idx = idx.saturating_sub(2);
force_update_time = true;
}
TimerAction::Quit => break,