mirror of
https://github.com/denoland/deno.git
synced 2025-01-03 04:48:52 -05:00
fix(windows): support special key presses in raw mode (#16904)
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
parent
918518b506
commit
715f35d635
1 changed files with 7 additions and 6 deletions
|
@ -16,10 +16,6 @@ use deno_core::error::custom_error;
|
||||||
use winapi::shared::minwindef::DWORD;
|
use winapi::shared::minwindef::DWORD;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use winapi::um::wincon;
|
use winapi::um::wincon;
|
||||||
#[cfg(windows)]
|
|
||||||
const RAW_MODE_MASK: DWORD = wincon::ENABLE_LINE_INPUT
|
|
||||||
| wincon::ENABLE_ECHO_INPUT
|
|
||||||
| wincon::ENABLE_PROCESSED_INPUT;
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
fn get_windows_handle(
|
fn get_windows_handle(
|
||||||
|
@ -85,11 +81,16 @@ fn op_stdin_set_raw(
|
||||||
{
|
{
|
||||||
return Err(Error::last_os_error().into());
|
return Err(Error::last_os_error().into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const RAW_MODE_MASK: DWORD = wincon::ENABLE_LINE_INPUT
|
||||||
|
| wincon::ENABLE_ECHO_INPUT
|
||||||
|
| wincon::ENABLE_PROCESSED_INPUT;
|
||||||
let new_mode = if is_raw {
|
let new_mode = if is_raw {
|
||||||
original_mode & !RAW_MODE_MASK
|
original_mode & !RAW_MODE_MASK | wincon::ENABLE_VIRTUAL_TERMINAL_INPUT
|
||||||
} else {
|
} else {
|
||||||
original_mode | RAW_MODE_MASK
|
original_mode | RAW_MODE_MASK & !wincon::ENABLE_VIRTUAL_TERMINAL_INPUT
|
||||||
};
|
};
|
||||||
|
|
||||||
// SAFETY: winapi call
|
// SAFETY: winapi call
|
||||||
if unsafe { consoleapi::SetConsoleMode(handle, new_mode) } == FALSE {
|
if unsafe { consoleapi::SetConsoleMode(handle, new_mode) } == FALSE {
|
||||||
return Err(Error::last_os_error().into());
|
return Err(Error::last_os_error().into());
|
||||||
|
|
Loading…
Reference in a new issue