|
|
@ -163,7 +163,6 @@ fn main() -> Result<()> {
|
|
|
|
loop {
|
|
|
|
loop {
|
|
|
|
match input.next()? {
|
|
|
|
match input.next()? {
|
|
|
|
input::Event::Key(event) => {
|
|
|
|
input::Event::Key(event) => {
|
|
|
|
debug!("Key Event: {}", event);
|
|
|
|
|
|
|
|
if event.down {
|
|
|
|
if event.down {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -177,6 +176,34 @@ fn main() -> Result<()> {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if event.code == key::TAB {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if event.code == key::BACKSPACE {
|
|
|
|
|
|
|
|
if line.backspace() {
|
|
|
|
|
|
|
|
let text = format!("\x1b[2D");
|
|
|
|
|
|
|
|
unsafe {
|
|
|
|
|
|
|
|
Error::check(Console::WriteConsoleA(stdout, text.as_bytes(), None, None))?;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
let tail = format!("{} ", line.tail());
|
|
|
|
|
|
|
|
let n = tail.chars().count();
|
|
|
|
|
|
|
|
unsafe {
|
|
|
|
|
|
|
|
Error::check(Console::WriteConsoleA(
|
|
|
|
|
|
|
|
stdout,
|
|
|
|
|
|
|
|
tail.as_bytes(),
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
None,
|
|
|
|
|
|
|
|
))?;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
let text = format!("\x1b[1D");
|
|
|
|
|
|
|
|
unsafe {
|
|
|
|
|
|
|
|
Error::check(Console::WriteConsoleA(stdout, text.as_bytes(), None, None))?;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if event.ctrl && event.code == key::D {
|
|
|
|
if event.ctrl && event.code == key::D {
|
|
|
|
unsafe {
|
|
|
|
unsafe {
|
|
|
|
CloseHandle(stdout);
|
|
|
|
CloseHandle(stdout);
|
|
|
@ -185,8 +212,8 @@ fn main() -> Result<()> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if event.ctrl && event.code == key::J {
|
|
|
|
if event.ctrl && event.code == key::J {
|
|
|
|
// red bullet
|
|
|
|
|
|
|
|
unsafe {
|
|
|
|
unsafe {
|
|
|
|
|
|
|
|
// red bullet
|
|
|
|
let text = "\x1b[31m\u{2022}\x1b[0m";
|
|
|
|
let text = "\x1b[31m\u{2022}\x1b[0m";
|
|
|
|
Error::check(Console::WriteConsoleA(stdout, text.as_bytes(), None, None))?;
|
|
|
|
Error::check(Console::WriteConsoleA(stdout, text.as_bytes(), None, None))?;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -220,7 +247,7 @@ fn main() -> Result<()> {
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
debug!("Unhandled Keyboard Event: {}", event);
|
|
|
|
debug!("Unhandled Keyboard Event: {:?}", event.code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
input::Event::Left => {
|
|
|
|
input::Event::Left => {
|
|
|
|
if line.back() {
|
|
|
|
if line.back() {
|
|
|
@ -238,6 +265,10 @@ fn main() -> Result<()> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
input::Event::Up => {},
|
|
|
|
|
|
|
|
input::Event::Down => {},
|
|
|
|
|
|
|
|
input::Event::Home => {},
|
|
|
|
|
|
|
|
input::Event::End => {},
|
|
|
|
input::Event::Focus(true) => {},
|
|
|
|
input::Event::Focus(true) => {},
|
|
|
|
input::Event::Focus(false) => {},
|
|
|
|
input::Event::Focus(false) => {},
|
|
|
|
input::Event::Menu(_command_id) => {},
|
|
|
|
input::Event::Menu(_command_id) => {},
|
|
|
|