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 | |
parent | 898ca615b5d573120a62cc01b2fb43f1d707f69f (diff) | |
download | textmode-505650dbca937c0d4cb64b29d75341f479a3b0d2.tar.gz textmode-505650dbca937c0d4cb64b29d75341f479a3b0d2.zip |
simplify
-rw-r--r-- | src/blocking/output.rs | 11 | ||||
-rw-r--r-- | src/output.rs | 14 |
2 files changed, 13 insertions, 12 deletions
diff --git a/src/blocking/output.rs b/src/blocking/output.rs index fa21617..c4db224 100644 --- a/src/blocking/output.rs +++ b/src/blocking/output.rs @@ -9,6 +9,11 @@ pub struct ScreenGuard { } impl ScreenGuard { + pub fn new() -> Result<Self> { + write_stdout(crate::INIT)?; + Ok(Self { cleaned_up: false }) + } + pub fn cleanup(&mut self) -> Result<()> { if self.cleaned_up { return Ok(()); @@ -51,11 +56,7 @@ impl crate::Textmode for Output {} impl Output { pub fn new() -> Result<(Self, ScreenGuard)> { - write_stdout(crate::INIT)?; - Ok(( - Self::new_without_screen(), - ScreenGuard { cleaned_up: false }, - )) + Ok((Self::new_without_screen(), ScreenGuard::new()?)) } pub fn new_without_screen() -> Self { 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 { |