|
|
|
@ -5,7 +5,10 @@ mod prompt;
|
|
|
|
|
|
|
|
|
|
use line::Line;
|
|
|
|
|
use prompt::Prompt;
|
|
|
|
|
use windows::Win32::{Foundation::HANDLE, System::Console};
|
|
|
|
|
use windows::Win32::{
|
|
|
|
|
Foundation::{CloseHandle, HANDLE},
|
|
|
|
|
System::Console,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
use anyhow::{Context, Result};
|
|
|
|
|
|
|
|
|
@ -199,6 +202,8 @@ pub fn stdout_handle() -> Result<HANDLE> {
|
|
|
|
|
fn setup_stdin() -> Result<()> {
|
|
|
|
|
let mut mode = Console::CONSOLE_MODE(0);
|
|
|
|
|
unsafe {
|
|
|
|
|
Console::SetConsoleCP(65001);
|
|
|
|
|
|
|
|
|
|
let handle = stdin_handle()?;
|
|
|
|
|
Error::check(Console::GetConsoleMode(handle, &mut mode))?;
|
|
|
|
|
|
|
|
|
@ -329,6 +334,13 @@ fn main() -> Result<()> {
|
|
|
|
|
prompt.print()?;
|
|
|
|
|
line.clear();
|
|
|
|
|
}
|
|
|
|
|
} else if key_code == 67
|
|
|
|
|
&& (modifiers & Console::LEFT_CTRL_PRESSED
|
|
|
|
|
== Console::LEFT_CTRL_PRESSED)
|
|
|
|
|
{
|
|
|
|
|
// this is CTRL+C
|
|
|
|
|
CloseHandle(stdout);
|
|
|
|
|
return Ok(());
|
|
|
|
|
} else if key_code == 74
|
|
|
|
|
&& (modifiers & Console::LEFT_CTRL_PRESSED
|
|
|
|
|
== Console::LEFT_CTRL_PRESSED)
|
|
|
|
|