Do not use chan_signal on windows

This commit is contained in:
Alexandre Bury 2018-06-18 16:50:09 -07:00
parent 26e5f51192
commit 3f16e8ed60
3 changed files with 19 additions and 2 deletions

View File

@ -38,7 +38,7 @@ version = "1.0.0"
optional = true
version = "1.3.1"
[dependencies.chan-signal]
[target.'cfg(unix)'.dependencies.chan-signal]
version = "0.3"
[dependencies.ncurses]

View File

@ -364,6 +364,19 @@ fn on_resize() {
pancurses::resize_term(size.y as i32, size.x as i32);
}
#[cfg(unix)]
fn resize_channel() -> chan::Receiver<chan_signal::Signal> {
chan_signal::notify(&[chan_signal::Signal::WINCH])
}
#[cfg(not(unix))]
fn resize_channel() -> chan::Receiver<()> {
let (sender, receiver) = chan::async();
// Forget the sender, so the channel doesn't close, but never completes.
::std::mem::forget(sender);
receiver
}
impl backend::Backend for Backend {
fn screen_size(&self) -> Vec2 {
// Coordinates are reversed here
@ -438,7 +451,7 @@ impl backend::Backend for Backend {
&mut self, event_sink: chan::Sender<Event>,
stops: chan::Receiver<bool>,
) {
let resize = chan_signal::notify(&[chan_signal::Signal::WINCH]);
let resize = resize_channel();
let (sender, receiver) = chan::async();
let needs_resize = Arc::clone(&self.needs_resize);

View File

@ -74,7 +74,11 @@ extern crate chan;
#[macro_use]
extern crate maplit;
// We use chan_signal to detect SIGWINCH.
// It's not how windows work, so no need to use that.
#[cfg(unix)]
extern crate chan_signal;
extern crate libc;
extern crate num;
extern crate owning_ref;