aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-04 22:43:41 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-04 22:43:41 -0500
commitde02603105db0b5bc0f21f17f5a74976aa8dbf2c (patch)
tree4e6beefb7c3e46bfee9631aedf012861003336a6
parent5ee80b05bf586853350daa410c970eb6ac4b2428 (diff)
downloadttyrec-bin-de02603105db0b5bc0f21f17f5a74976aa8dbf2c.tar.gz
ttyrec-bin-de02603105db0b5bc0f21f17f5a74976aa8dbf2c.zip
let's not rely on reading back display data
-rw-r--r--src/bin/ttyplay/display.rs8
-rw-r--r--src/bin/ttyplay/main.rs46
2 files changed, 27 insertions, 27 deletions
diff --git a/src/bin/ttyplay/display.rs b/src/bin/ttyplay/display.rs
index 38e3bf3..f5bcb00 100644
--- a/src/bin/ttyplay/display.rs
+++ b/src/bin/ttyplay/display.rs
@@ -23,18 +23,10 @@ impl Display {
self.current_frame = idx;
}
- pub fn get_current_frame(&self) -> usize {
- self.current_frame
- }
-
pub fn total_frames(&mut self, n: usize) {
self.total_frames = n;
}
- pub fn get_total_frames(&self) -> usize {
- self.total_frames
- }
-
pub fn done_loading(&mut self) {
self.done_loading = true;
}
diff --git a/src/bin/ttyplay/main.rs b/src/bin/ttyplay/main.rs
index b4b5abc..6f858fd 100644
--- a/src/bin/ttyplay/main.rs
+++ b/src/bin/ttyplay/main.rs
@@ -19,7 +19,10 @@ struct Opt {
enum TimerAction {
Pause,
- GotoFrame(usize),
+ FirstFrame,
+ LastFrame,
+ NextFrame,
+ PreviousFrame,
Quit,
}
@@ -125,8 +128,25 @@ fn spawn_timer_task(
.await
.unwrap();
}
- TimerAction::GotoFrame(new_idx) => {
- idx = new_idx;
+ TimerAction::FirstFrame => {
+ idx = 0;
+ force_update_time = true;
+ }
+ TimerAction::LastFrame => {
+ idx = frames.lock_arc().await.count() - 1;
+ force_update_time = true;
+ }
+ 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;
+ }
force_update_time = true;
}
TimerAction::Quit => break,
@@ -185,31 +205,19 @@ async fn async_main(opt: Opt) -> anyhow::Result<()> {
continue;
}
event::Event::FirstFrame => {
- timer_w.send(TimerAction::GotoFrame(0)).await?;
+ timer_w.send(TimerAction::FirstFrame).await?;
continue;
}
event::Event::LastFrame => {
- timer_w
- .send(TimerAction::GotoFrame(
- display.get_total_frames() - 1,
- ))
- .await?;
+ timer_w.send(TimerAction::LastFrame).await?;
continue;
}
event::Event::NextFrame => {
- timer_w
- .send(TimerAction::GotoFrame(
- display.get_current_frame() + 1,
- ))
- .await?;
+ timer_w.send(TimerAction::NextFrame).await?;
continue;
}
event::Event::PreviousFrame => {
- timer_w
- .send(TimerAction::GotoFrame(
- display.get_current_frame() - 1,
- ))
- .await?;
+ timer_w.send(TimerAction::PreviousFrame).await?;
continue;
}
event::Event::FrameTransition((idx, screen)) => {