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