Fix compilation error on BLT backend

This commit is contained in:
Alexandre Bury 2018-07-19 20:13:37 -07:00
parent af4e55ed18
commit 5dfc27bd9f
2 changed files with 10 additions and 8 deletions

View File

@ -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<Option<Event>>,
input_request: Receiver<backend::InputRequest>,
input_requests: Receiver<backend::InputRequest>,
) {
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;
}
}

View File

@ -43,7 +43,6 @@ pub struct Cursive {
cb_sink: Sender<Box<CbFunc>>,
event_source: Receiver<Option<Event>>,
event_sink: Sender<Option<Event>>,
// Sends true or false after each event.
input_trigger: Sender<backend::InputRequest>,
@ -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,