diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 42 |
1 files changed, 14 insertions, 28 deletions
diff --git a/src/main.rs b/src/main.rs index 3017995..2836b2c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,35 +4,10 @@ use std::process::Command; use std::ffi::OsStr; use std::os::unix::ffi::OsStrExt; use std::path::Path; -use termios::*; -struct ScopedRawMode { - fd: i32, - settings: Termios, -} - -impl Drop for ScopedRawMode { - fn drop(&mut self) { - self.disable(); - } -} - -impl ScopedRawMode { - fn on_fd(fd: i32) -> Self { - let settings = Termios::from_fd(fd).unwrap(); - Self { fd, settings } - } - - fn enable(&self) { - let mut settings = self.settings.clone(); - cfmakeraw(&mut settings); - tcsetattr(self.fd, TCSANOW, &settings).unwrap(); - } - - fn disable(&self) { - tcsetattr(self.fd, TCSANOW, &self.settings).unwrap(); - } -} +mod raw; +mod parse; +use raw::*; macro_rules! print { ($($x:tt)*) => {{ @@ -41,6 +16,17 @@ macro_rules! print { }} } +macro_rules! println { + () => {{ + println!("") + }}; + ($($x:tt)*) => {{ + write!(io::stdout(), $($x)*).unwrap(); + write!(io::stdout(), "\r\n").unwrap(); + io::stdout().flush().unwrap(); + }}; +} + struct LineBuffer { pre: Vec<u8>, post: Vec<u8>, |
