aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-04 20:19:58 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-04 20:19:58 -0500
commitde4c2b1de367aa2b6d20ec0c90f317e19d245ae9 (patch)
treeb4cd7261fdd046131aff66fbf4bf030651ae69ce
parent9aea0a1471072f9dc19c4c0e07eb98cb5bc40828 (diff)
downloadttyrec-bin-de4c2b1de367aa2b6d20ec0c90f317e19d245ae9.tar.gz
ttyrec-bin-de4c2b1de367aa2b6d20ec0c90f317e19d245ae9.zip
allow hiding the ui when paused
-rw-r--r--src/bin/ttyplay/display.rs8
-rw-r--r--src/bin/ttyplay/event.rs1
-rw-r--r--src/bin/ttyplay/input.rs1
-rw-r--r--src/bin/ttyplay/main.rs4
4 files changed, 13 insertions, 1 deletions
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(&current_screen, &mut output).await?;
+ }
event::Event::Quit => {
timer_w.send(TimerAction::Quit).await?;
break;