diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-03-09 03:22:06 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-03-09 03:22:06 -0500 |
commit | 505650dbca937c0d4cb64b29d75341f479a3b0d2 (patch) | |
tree | 2a17d0e2eac60ac4c5b9b6b1da37a2ee9a8c8920 /src/output.rs | |
parent | 898ca615b5d573120a62cc01b2fb43f1d707f69f (diff) | |
download | textmode-505650dbca937c0d4cb64b29d75341f479a3b0d2.tar.gz textmode-505650dbca937c0d4cb64b29d75341f479a3b0d2.zip |
simplify
Diffstat (limited to 'src/output.rs')
-rw-r--r-- | src/output.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/output.rs b/src/output.rs index 52495d0..311443b 100644 --- a/src/output.rs +++ b/src/output.rs @@ -9,12 +9,17 @@ pub struct ScreenGuard { } impl ScreenGuard { + pub async fn new() -> Result<Self> { + write_stdout(crate::INIT).await?; + Ok(Self { cleaned_up: false }) + } + pub async fn cleanup(&mut self) -> Result<()> { if self.cleaned_up { return Ok(()); } self.cleaned_up = true; - write_stdout(super::DEINIT).await + write_stdout(crate::DEINIT).await } } @@ -53,12 +58,7 @@ impl super::Textmode for Output {} impl Output { pub async fn new() -> Result<(Self, ScreenGuard)> { - write_stdout(super::INIT).await?; - - Ok(( - Self::new_without_screen(), - ScreenGuard { cleaned_up: false }, - )) + Ok((Self::new_without_screen(), ScreenGuard::new().await?)) } pub fn new_without_screen() -> Self { |