diff options
Diffstat (limited to 'src/output.rs')
-rw-r--r-- | src/output.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/output.rs b/src/output.rs index 28411e1..1e0ed43 100644 --- a/src/output.rs +++ b/src/output.rs @@ -41,6 +41,8 @@ impl Drop for ScreenGuard { pub struct Output { stdout: blocking::Unblock<std::io::Stdout>, + screen: Option<ScreenGuard>, + cur: vt100::Parser, next: vt100::Parser, } @@ -66,8 +68,10 @@ impl crate::private::Output for Output { impl crate::Textmode for Output {} impl Output { - pub async fn new() -> Result<(Self, ScreenGuard)> { - Ok((Self::new_without_screen(), ScreenGuard::new().await?)) + pub async fn new() -> Result<Self> { + let mut self_ = Self::new_without_screen(); + self_.screen = Some(ScreenGuard::new().await?); + Ok(self_) } pub fn new_without_screen() -> Self { @@ -81,11 +85,16 @@ impl Output { let next = vt100::Parser::new(rows, cols, 0); Self { stdout: blocking::Unblock::new(std::io::stdout()), + screen: None, cur, next, } } + pub fn take_screen_guard(&mut self) -> Option<ScreenGuard> { + self.screen.take() + } + pub async fn refresh(&mut self) -> Result<()> { let diff = self.next().screen().state_diff(self.cur().screen()); write_stdout(&mut self.stdout, &diff).await?; |