From de4c2b1de367aa2b6d20ec0c90f317e19d245ae9 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 4 Dec 2021 20:19:58 -0500 Subject: allow hiding the ui when paused --- src/bin/ttyplay/display.rs | 8 +++++++- src/bin/ttyplay/event.rs | 1 + src/bin/ttyplay/input.rs | 1 + src/bin/ttyplay/main.rs | 4 ++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/bin/ttyplay/display.rs b/src/bin/ttyplay/display.rs index 486cb0b..b1836d8 100644 --- a/src/bin/ttyplay/display.rs +++ b/src/bin/ttyplay/display.rs @@ -5,6 +5,7 @@ pub struct Display { total_frames: usize, done_loading: bool, paused: bool, + show_ui: bool, } impl Display { @@ -14,6 +15,7 @@ impl Display { total_frames: 0, done_loading: false, paused: false, + show_ui: true, } } @@ -41,6 +43,10 @@ impl Display { self.paused = paused; } + pub fn toggle_ui(&mut self) { + self.show_ui = !self.show_ui; + } + pub async fn render( &self, screen: &vt100::Screen, @@ -49,7 +55,7 @@ impl Display { output.clear(); output.move_to(0, 0); output.write(&screen.contents_formatted()); - if self.paused { + if self.paused && self.show_ui { let pos = output.screen().cursor_position(); output.move_to(0, 0); diff --git a/src/bin/ttyplay/event.rs b/src/bin/ttyplay/event.rs index 677f488..55f4da1 100644 --- a/src/bin/ttyplay/event.rs +++ b/src/bin/ttyplay/event.rs @@ -8,5 +8,6 @@ pub enum Event { LastFrame, NextFrame, PreviousFrame, + ToggleUi, Quit, } diff --git a/src/bin/ttyplay/input.rs b/src/bin/ttyplay/input.rs index dbdedd6..d7cdc57 100644 --- a/src/bin/ttyplay/input.rs +++ b/src/bin/ttyplay/input.rs @@ -11,6 +11,7 @@ pub async fn handle_input( textmode::Key::Char('h' | 'p') => crate::event::Event::PreviousFrame, textmode::Key::Char('q') => crate::event::Event::Quit, textmode::Key::Char(' ') => crate::event::Event::Pause, + textmode::Key::Ctrl(b'i') => crate::event::Event::ToggleUi, _ => return Ok(()), }; diff --git a/src/bin/ttyplay/main.rs b/src/bin/ttyplay/main.rs index 63a2658..a98f5f9 100644 --- a/src/bin/ttyplay/main.rs +++ b/src/bin/ttyplay/main.rs @@ -215,6 +215,10 @@ async fn async_main(opt: Opt) -> anyhow::Result<()> { )) .await?; } + event::Event::ToggleUi => { + display.toggle_ui(); + display.render(¤t_screen, &mut output).await?; + } event::Event::Quit => { timer_w.send(TimerAction::Quit).await?; break; -- cgit v1.2.3-54-g00ecf