|
|
|
@ -388,7 +388,7 @@ fn main() -> Result<()> {
|
|
|
|
|
|
|
|
|
|
// CTRL-U to erase to the beginning of the line
|
|
|
|
|
if event.ctrl && event.code == key::U {
|
|
|
|
|
info!("» clear-left");
|
|
|
|
|
info!("» clear left");
|
|
|
|
|
let n = line.clear_left();
|
|
|
|
|
if n > 0 {
|
|
|
|
|
// move left by the number of elements removed
|
|
|
|
@ -411,6 +411,34 @@ fn main() -> Result<()> {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CTRL-A to move to the beginning of the line
|
|
|
|
|
if event.ctrl && event.code == key::A {
|
|
|
|
|
info!("» seek left");
|
|
|
|
|
let n = line.seek_left();
|
|
|
|
|
if n > 0 {
|
|
|
|
|
// move left by the distance seeked
|
|
|
|
|
let text = format!("\x1b[{}D", n);
|
|
|
|
|
unsafe {
|
|
|
|
|
Error::check(Console::WriteConsoleA(stdout, text.as_bytes(), None, None))?;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CTRL-E to move to the end of the line
|
|
|
|
|
if event.ctrl && event.code == key::E {
|
|
|
|
|
info!("» seek right");
|
|
|
|
|
let n = line.seek_right();
|
|
|
|
|
if n > 0 {
|
|
|
|
|
// move right by the distance seeked
|
|
|
|
|
let text = format!("\x1b[{}C", n);
|
|
|
|
|
unsafe {
|
|
|
|
|
Error::check(Console::WriteConsoleA(stdout, text.as_bytes(), None, None))?;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: something better here, this is crappy. I should be checking characters
|
|
|
|
|
// based on their unicode categories, not this garbo
|
|
|
|
|
if !event.char.is_control() {
|
|
|
|
|