ok ctrl+c works

parse-tree
Jordan Orelli 2 years ago
parent b548b908e7
commit b8e001f008

@ -27,6 +27,7 @@ impl<W> Log<W>
where
W: io::Write,
{
#[allow(dead_code)]
pub fn from_writer(w: W) -> Self {
Self {
out: Arc::new(Mutex::new(w)),

@ -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)

Loading…
Cancel
Save