|
|
@ -198,18 +198,23 @@ fn main() -> Result<()> {
|
|
|
|
if !event.char.is_control() {
|
|
|
|
if !event.char.is_control() {
|
|
|
|
line.insert(event.char);
|
|
|
|
line.insert(event.char);
|
|
|
|
|
|
|
|
|
|
|
|
let mut buf = [0 as u8; 8];
|
|
|
|
let tail = line.tail();
|
|
|
|
let s = event.char.encode_utf8(&mut buf);
|
|
|
|
let n = tail.chars().count();
|
|
|
|
|
|
|
|
|
|
|
|
// write everything from the current line cursor out to the output buffer. Then
|
|
|
|
// write everything from the current line cursor out to the output buffer. Then
|
|
|
|
// rewind the cursor in the output buffer to where it was.
|
|
|
|
// rewind the cursor in the output buffer to where it was.
|
|
|
|
unsafe {
|
|
|
|
unsafe {
|
|
|
|
Error::check(Console::WriteConsoleA(
|
|
|
|
Error::check(Console::WriteConsoleA(
|
|
|
|
stdout,
|
|
|
|
stdout,
|
|
|
|
s.as_bytes(),
|
|
|
|
tail.as_bytes(),
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
))?;
|
|
|
|
))?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if n > 1 {
|
|
|
|
|
|
|
|
let text = format!("\x1b[{}D", n-1);
|
|
|
|
|
|
|
|
Error::check(Console::WriteConsoleA(stdout, text.as_bytes(), None, None))?;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -220,7 +225,7 @@ fn main() -> Result<()> {
|
|
|
|
debug!("back!");
|
|
|
|
debug!("back!");
|
|
|
|
line.back();
|
|
|
|
line.back();
|
|
|
|
unsafe {
|
|
|
|
unsafe {
|
|
|
|
let text = "\x1b[D";
|
|
|
|
let text = "\x1b[D"; // lol this sucks
|
|
|
|
Error::check(Console::WriteConsoleA(stdout, text.as_bytes(), None, None))?;
|
|
|
|
Error::check(Console::WriteConsoleA(stdout, text.as_bytes(), None, None))?;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|