Skip to content

Commit 318853e

Browse files
committed
Use windows-sys to minimize Windows dependencies.
1 parent bc47c59 commit 318853e

File tree

3 files changed

+25
-99
lines changed

3 files changed

+25
-99
lines changed

Cargo.lock

Lines changed: 18 additions & 94 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ crossterm = { version = "0.29.0", features = [
4242
nix = { version = "0.29", features = ["signal"], optional = true }
4343

4444
[target.'cfg(windows)'.dependencies]
45-
windows = { version = "0.61.3", features = ["Win32_System_Console"], optional = true }
45+
windows-sys = { version = "0.60.2", features = ["Win32_System_Console"], optional = true }
4646

4747

4848
[dev-dependencies]
@@ -53,7 +53,7 @@ serde_json = "1.0.108"
5353
tempfile = "3.8.1"
5454

5555
[features]
56-
clipboard = ["dep:crossterm", "dep:windows", "dep:nix"]
56+
clipboard = ["dep:crossterm", "dep:windows-sys", "dep:nix"]
5757
default = ["clipboard"]
5858

5959
[patch.crates-io]

src/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ async fn send(args: SendArgs) -> anyhow::Result<()> {
751751
unistd::Pid,
752752
};
753753
#[cfg(windows)]
754-
use windows::Win32::System::Console::{GenerateConsoleCtrlEvent, CTRL_C_EVENT};
754+
use windows_sys::Win32::System::Console::{GenerateConsoleCtrlEvent, CTRL_C_EVENT};
755755

756756
// Add command to the clipboard
757757
if args.clipboard {
@@ -784,13 +784,15 @@ async fn send(args: SendArgs) -> anyhow::Result<()> {
784784
})) => {
785785
disable_raw_mode()
786786
.unwrap_or_else(|e| eprintln!("Failed to disable raw mode: {e}"));
787+
787788
#[cfg(unix)]
788789
kill(Pid::from_raw(0), Some(Signal::SIGINT))
789790
.unwrap_or_else(|e| eprintln!("Failed to end process: {e}"));
790791

791792
#[cfg(windows)]
792-
unsafe { GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0) }
793-
.unwrap_or_else(|e| eprintln!("Failed to end process: {e}"));
793+
if unsafe { GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0) } != 0 {
794+
eprintln!("Failed to end process: {}", std::io::Error::last_os_error());
795+
}
794796
}
795797
_ => {}
796798
})

0 commit comments

Comments
 (0)