diff --git a/Cargo.lock b/Cargo.lock index 30b5c8c..768ee2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,7 +59,7 @@ version = "0.11.0" dependencies = [ "libc", "pyo3", - "windows", + "windows-sys", ] [[package]] @@ -173,66 +173,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" [[package]] -name = "windows" -version = "0.58.0" +name = "windows-sys" +version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-core", - "windows-targets", -] - -[[package]] -name = "windows-core" -version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" -dependencies = [ - "windows-implement", - "windows-interface", - "windows-result", - "windows-strings", - "windows-targets", -] - -[[package]] -name = "windows-implement" -version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "windows-interface" -version = "0.58.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "windows-result" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-strings" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" -dependencies = [ - "windows-result", "windows-targets", ] diff --git a/Cargo.toml b/Cargo.toml index c122864..2c87256 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,16 +20,19 @@ pyo3 = { version = "0.22.5", features = ["extension-module", "abi3", "abi3-py311 [target.'cfg(unix)'.dependencies] libc = { version = "0.2.161", optional = true } -[target.'cfg(windows)'.dependencies.windows] -version = "0.58.0" +[target.'cfg(windows)'.dependencies.windows-sys] +version = "0.59.0" optional = true +features = [ + "Win32_System_Console" +] [features] default = ["f64", "term"] f64 = [] gamut = [] pyffi = ["dep:pyo3"] -term = ["dep:libc", "dep:windows"] +term = ["dep:libc", "dep:windows-sys"] [lib] diff --git a/src/term/sys/windows.rs b/src/term/sys/windows.rs index 7bc33ef..8b63034 100644 --- a/src/term/sys/windows.rs +++ b/src/term/sys/windows.rs @@ -6,9 +6,15 @@ //! For that same reason, [`Config`], [`Reader`], and [`Writer`] must not be //! directly exposed to application code. -use std::io::{Error, ErrorKind, Result}; +use std::fs::OpenOptions; +use std::io::{Error, ErrorKind, Read, Result, Write}; use std::os::windows::io::{AsRawHandle, OwnedHandle}; -use std::ptr::{from_mut, from_ref}; +use std::ptr::from_mut; + +use windows_sys::Win32::System::Console::{GetConsoleMode, SetConsoleMode}; + +use super::RawHandle; +use crate::term::Options; /// A trait for converting Windows status BOOL to Rust std::io results. trait IntoResult {