diff options
| author | Jonas Maier <> | 2026-03-05 07:26:59 +0100 |
|---|---|---|
| committer | Jonas Maier <> | 2026-03-05 07:26:59 +0100 |
| commit | 4b83b63ddb81817ea7cc418f1b61f687ba813085 (patch) | |
| tree | 02dfad0d4235d44545a930a1bd2304b2c6d36031 /src/main.rs | |
| parent | d4050c3a8cfabd4ae77d001d665573729d28a096 (diff) | |
| download | pish-4b83b63ddb81817ea7cc418f1b61f687ba813085.tar.gz | |
begin of a parser
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>, |
