diff --git a/src/control.rs b/src/control.rs index 7b65619..1bcd41d 100644 --- a/src/control.rs +++ b/src/control.rs @@ -44,7 +44,9 @@ pub trait TermWrite { self.csi(b"?25l") } - // TODO insert mode + // TODO + // fn mode + /// Reset the rendition mode. /// diff --git a/src/lib.rs b/src/lib.rs index 3ad3d47..8e06f54 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,7 @@ mod error; pub use error::TerminalError; mod raw; -pub use raw::{IntoRawMode, TerminalRestorer}; +pub use raw::{IntoRawMode, RawTerminal}; mod size; pub use size::terminal_size; diff --git a/src/raw.rs b/src/raw.rs index 11fa580..6c9912d 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -6,12 +6,12 @@ use TerminalError; /// A terminal restorer, which keeps the previous state of the terminal, and restores it, when /// dropped. #[cfg(target_os = "redox")] -pub struct TerminalRestorer { +pub struct RawTerminal { output: W, } #[cfg(target_os = "redox")] -impl Drop for TerminalRestorer { +impl Drop for RawTerminal { fn drop(&mut self) { use TermControl; self.csi(b"R"); @@ -23,27 +23,27 @@ use termios::Termios; /// A terminal restorer, which keeps the previous state of the terminal, and restores it, when /// dropped. #[cfg(not(target_os = "redox"))] -pub struct TerminalRestorer { +pub struct RawTerminal { prev_ios: Termios, output: W, } #[cfg(not(target_os = "redox"))] -impl Drop for TerminalRestorer { +impl Drop for RawTerminal { fn drop(&mut self) { use termios::set_terminal_attr; set_terminal_attr(&mut self.prev_ios as *mut _); } } -impl Deref for TerminalRestorer { +impl Deref for RawTerminal { type Target = W; fn deref(&self) -> &W { &self.output } } -impl DerefMut for TerminalRestorer { +impl DerefMut for RawTerminal { fn deref_mut(&mut self) -> &mut W { &mut self.output } @@ -56,12 +56,12 @@ pub trait IntoRawMode: Sized { /// Raw mode means that stdin won't be printed (it will instead have to be written manually by the /// program). Furthermore, the input isn't canonicalised or buffered (that is, you can read from /// stdin one byte of a time). The output is neither modified in any way. - fn into_raw_mode(self) -> Result, TerminalError>; + fn into_raw_mode(self) -> Result, TerminalError>; } impl IntoRawMode for W { #[cfg(not(target_os = "redox"))] - fn into_raw_mode(self) -> Result, TerminalError> { + fn into_raw_mode(self) -> Result, TerminalError> { use termios::{cfmakeraw, get_terminal_attr, set_terminal_attr}; let (mut ios, err) = get_terminal_attr(); @@ -77,20 +77,20 @@ impl IntoRawMode for W { if set_terminal_attr(&mut ios as *mut _) != 0 { Err(TerminalError::SetAttrError) } else { - Ok(TerminalRestorer { + Ok(RawTerminal { prev_ios: prev_ios, output: self, }) } } #[cfg(target_os = "redox")] - fn into_raw_mode(self) -> Result, TerminalError> { + fn into_raw_mode(self) -> Result, TerminalError> { use TermControl; if let Err(_) = self.csi("r") { Err(TerminalError::StdoutError) } else { - Ok(TerminalRestorer { + Ok(RawTerminal { output: self, }) }