From b64b10f40bbdae061cde40cbad3dccd3efcec6d4 Mon Sep 17 00:00:00 2001 From: Nathan Lilienthal Date: Fri, 12 Oct 2018 01:40:18 -0400 Subject: [PATCH] Add ability to suspend/activate raw mode on RawTerminal --- src/raw.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/raw.rs b/src/raw.rs index 5421d56..0dbfb56 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -101,6 +101,20 @@ impl IntoRawMode for W { } } +impl RawTerminal { + pub fn suspend_raw_mode(&self) -> io::Result<()> { + set_terminal_attr(&self.prev_ios)?; + Ok(()) + } + + pub fn activate_raw_mode(&self) -> io::Result<()> { + let mut ios = get_terminal_attr()?; + raw_terminal_attr(&mut ios); + set_terminal_attr(&ios)?; + Ok(()) + } +} + #[cfg(test)] mod test { use super::*;