echo the line

parse-tree
Jordan Orelli 2 years ago
parent c7a0a404fe
commit ef41b94d2d

@ -249,6 +249,7 @@ fn main() -> Result<()> {
let stdin = stdin_handle()?; let stdin = stdin_handle()?;
let stdout = stdout_handle()?; let stdout = stdout_handle()?;
let mut buf = [Console::INPUT_RECORD::default(); 100]; let mut buf = [Console::INPUT_RECORD::default(); 100];
let mut line = String::new();
loop { loop {
let mut n: u32 = 0; let mut n: u32 = 0;
@ -305,8 +306,24 @@ fn main() -> Result<()> {
None, None,
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 = "•"; let text = "•";
Error::check(Console::WriteConsoleA( Error::check(Console::WriteConsoleA(
stdout, stdout,
@ -317,8 +334,9 @@ fn main() -> Result<()> {
} else { } else {
if let Some(c) = char::from_u32(event.uChar.UnicodeChar as u32) { if let Some(c) = char::from_u32(event.uChar.UnicodeChar as u32) {
if !c.is_control() { 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); let s = c.encode_utf8(&mut buf);
line.push_str(s);
Error::check(Console::WriteConsoleW( Error::check(Console::WriteConsoleW(
stdout, stdout,
s.as_bytes(), s.as_bytes(),

Loading…
Cancel
Save