From 5dfc27bd9f400cc717a3b3af0fb112bdf1d2ad21 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Thu, 19 Jul 2018 20:13:37 -0700 Subject: [PATCH] Fix compilation error on BLT backend --- src/backend/blt.rs | 14 +++++++++----- src/cursive.rs | 4 +--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/backend/blt.rs b/src/backend/blt.rs index 7b9173b..6b8d110 100644 --- a/src/backend/blt.rs +++ b/src/backend/blt.rs @@ -6,6 +6,7 @@ extern crate bear_lib_terminal; use std::collections::HashSet; +use std::thread; use std::time::{Duration, Instant}; use self::bear_lib_terminal::geometry::Size; @@ -13,7 +14,7 @@ use self::bear_lib_terminal::terminal::{ self, state, Event as BltEvent, KeyCode, }; use self::bear_lib_terminal::Color as BltColor; -use crossbeam_channel::{Receiver, Sender}; +use crossbeam_channel::{self, Receiver, Sender}; use backend; use event::{Event, Key, MouseButton, MouseEvent}; @@ -316,7 +317,7 @@ impl backend::Backend for Backend { fn start_input_thread( &mut self, event_sink: Sender>, - input_request: Receiver, + input_requests: Receiver, ) { let receiver = self.inner_receiver.clone(); @@ -332,14 +333,17 @@ impl backend::Backend for Backend { fn prepare_input(&mut self, input_request: backend::InputRequest) { match input_request { - backend::InputRequest::Peek => event_sink.send(self.parse_next()), + backend::InputRequest::Peek => { + let event = self.parse_next(); + self.inner_sender.send(event); + } backend::InputRequest::Block => { - let timeout = ::std::time::Duration::from_millis(30); + let timeout = Duration::from_millis(30); // Wait for up to `timeout_ms`. let start = Instant::now(); while start.elapsed() < timeout { if let Some(event) = self.parse_next() { - event_sink.send(Some(event)); + self.inner_sender.send(Some(event)); return; } } diff --git a/src/cursive.rs b/src/cursive.rs index 3dfbb3b..73f3c57 100644 --- a/src/cursive.rs +++ b/src/cursive.rs @@ -43,7 +43,6 @@ pub struct Cursive { cb_sink: Sender>, event_source: Receiver>, - event_sink: Sender>, // Sends true or false after each event. input_trigger: Sender, @@ -141,7 +140,7 @@ impl Cursive { let (input_sink, input_source) = crossbeam_channel::bounded(0); let mut backend = backend_init(); - backend.start_input_thread(event_sink.clone(), input_source); + backend.start_input_thread(event_sink, input_source); Cursive { fps: 0, @@ -155,7 +154,6 @@ impl Cursive { cb_source, cb_sink, event_source, - event_sink, backend, input_trigger: input_sink, expecting_event: false,