diff --git a/src/main.rs b/src/main.rs index e1dc178..8a2dcff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -249,6 +249,7 @@ fn main() -> Result<()> { let stdin = stdin_handle()?; let stdout = stdout_handle()?; let mut buf = [Console::INPUT_RECORD::default(); 100]; + let mut line = String::new(); loop { let mut n: u32 = 0; @@ -305,8 +306,24 @@ fn main() -> Result<()> { None, None, ))?; + Error::check(Console::WriteConsoleA( + stdout, + line.as_bytes(), + None, + None, + ))?; + Error::check(Console::WriteConsoleA( + stdout, + "\r\n".as_bytes(), + None, + None, + ))?; + line = String::new(); } - } else if key_code == 74 && modifiers | Console::LEFT_CTRL_PRESSED > 0 { + } else if key_code == 74 + && (modifiers & Console::LEFT_CTRL_PRESSED + == Console::LEFT_CTRL_PRESSED) + { let text = "•"; Error::check(Console::WriteConsoleA( stdout, @@ -317,8 +334,9 @@ fn main() -> Result<()> { } else { if let Some(c) = char::from_u32(event.uChar.UnicodeChar as u32) { if !c.is_control() { - let mut buf = [0 as u8; 2]; + let mut buf = [0 as u8; 8]; let s = c.encode_utf8(&mut buf); + line.push_str(s); Error::check(Console::WriteConsoleW( stdout, s.as_bytes(),