mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Update dependencies
This commit is contained in:
parent
a6d9b46bf3
commit
79e23bb70e
@ -28,7 +28,7 @@ unicode-width = "0.1"
|
|||||||
xi-unicode = "0.1"
|
xi-unicode = "0.1"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
term_size = { version = "0.3", optional = true }
|
term_size = { version = "0.3", optional = true }
|
||||||
crossbeam-channel = "0.2"
|
crossbeam-channel = "0.3"
|
||||||
|
|
||||||
[dependencies.num]
|
[dependencies.num]
|
||||||
default-features = false
|
default-features = false
|
||||||
@ -55,7 +55,7 @@ version = "0.16"
|
|||||||
[dependencies.pulldown-cmark]
|
[dependencies.pulldown-cmark]
|
||||||
default-features = false
|
default-features = false
|
||||||
optional = true
|
optional = true
|
||||||
version = "0.1"
|
version = "0.2"
|
||||||
|
|
||||||
[dependencies.termion]
|
[dependencies.termion]
|
||||||
optional = true
|
optional = true
|
||||||
@ -65,7 +65,7 @@ version = "1.5"
|
|||||||
version = "0.1"
|
version = "0.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = "0.5"
|
rand = "0.6"
|
||||||
pretty-bytes = "0.2"
|
pretty-bytes = "0.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -52,7 +52,7 @@ fn phase_1(s: &mut Cursive) {
|
|||||||
fake_load(n_max, &counter);
|
fake_load(n_max, &counter);
|
||||||
|
|
||||||
// When we're done, send a callback through the channel
|
// When we're done, send a callback through the channel
|
||||||
cb.send(Box::new(coffee_break));
|
cb.send(Box::new(coffee_break)).unwrap();
|
||||||
})
|
})
|
||||||
.full_width(),
|
.full_width(),
|
||||||
));
|
));
|
||||||
@ -110,7 +110,7 @@ fn phase_2(s: &mut Cursive) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cb.send(Box::new(final_step));
|
cb.send(Box::new(final_step)).unwrap();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,8 +124,10 @@ fn final_step(s: &mut Cursive) {
|
|||||||
TextView::new(
|
TextView::new(
|
||||||
"Time travel was a success!\n\
|
"Time travel was a success!\n\
|
||||||
We went forward a few seconds!!",
|
We went forward a few seconds!!",
|
||||||
).center(),
|
)
|
||||||
).button("That's it?", |s| s.quit()),
|
.center(),
|
||||||
|
)
|
||||||
|
.button("That's it?", |s| s.quit()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// When we're done, shut down the application
|
// When we're done, shut down the application
|
||||||
cb_sink.send(Box::new(|s: &mut Cursive| s.quit()));
|
cb_sink.send(Box::new(|s: &mut Cursive| s.quit())).unwrap();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add a single view: progress status
|
// Add a single view: progress status
|
||||||
@ -112,8 +112,10 @@ fn main() {
|
|||||||
(0, 2),
|
(0, 2),
|
||||||
&format!("Speed: {}/s", convert(speed)),
|
&format!("Speed: {}/s", convert(speed)),
|
||||||
);
|
);
|
||||||
}).fixed_size((25, 3)),
|
})
|
||||||
).with(|l| {
|
.fixed_size((25, 3)),
|
||||||
|
)
|
||||||
|
.with(|l| {
|
||||||
// If we have a file length, add a progress bar
|
// If we have a file length, add a progress bar
|
||||||
if let Some(len) = len {
|
if let Some(len) = len {
|
||||||
l.add_child(
|
l.add_child(
|
||||||
|
@ -329,8 +329,12 @@ impl backend::Backend for Backend {
|
|||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
for _ in input_requests {
|
for _ in input_requests {
|
||||||
match receiver.recv() {
|
match receiver.recv() {
|
||||||
None => return,
|
Err(_) => return,
|
||||||
Some(event) => event_sink.send(event),
|
Ok(event) => {
|
||||||
|
if event_sink.send(event).is_err() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -340,7 +344,7 @@ impl backend::Backend for Backend {
|
|||||||
match input_request {
|
match input_request {
|
||||||
backend::InputRequest::Peek => {
|
backend::InputRequest::Peek => {
|
||||||
let event = self.parse_next();
|
let event = self.parse_next();
|
||||||
self.inner_sender.send(event);
|
self.inner_sender.send(event).unwrap();
|
||||||
}
|
}
|
||||||
backend::InputRequest::Block => {
|
backend::InputRequest::Block => {
|
||||||
let timeout = Duration::from_millis(30);
|
let timeout = Duration::from_millis(30);
|
||||||
@ -348,11 +352,11 @@ impl backend::Backend for Backend {
|
|||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
while start.elapsed() < timeout {
|
while start.elapsed() < timeout {
|
||||||
if let Some(event) = self.parse_next() {
|
if let Some(event) = self.parse_next() {
|
||||||
self.inner_sender.send(Some(event));
|
self.inner_sender.send(Some(event)).unwrap();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.inner_sender.send(Some(Event::Refresh));
|
self.inner_sender.send(Some(Event::Refresh)).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,7 +350,9 @@ impl backend::Backend for Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Do the actual polling & parsing.
|
// Do the actual polling & parsing.
|
||||||
event_sink.send(parser.parse_next());
|
if event_sink.send(parser.parse_next()).is_err() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// The request channel is closed, which means Cursive has been
|
// The request channel is closed, which means Cursive has been
|
||||||
// dropped, so stop the resize-detection thread as well.
|
// dropped, so stop the resize-detection thread as well.
|
||||||
|
@ -484,7 +484,7 @@ impl backend::Backend for Backend {
|
|||||||
input_parser.window.timeout(-1);
|
input_parser.window.timeout(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event_sink.send(input_parser.parse_next());
|
event_sink.send(input_parser.parse_next()).unwrap();
|
||||||
}
|
}
|
||||||
running.store(false, Ordering::Relaxed);
|
running.store(false, Ordering::Relaxed);
|
||||||
});
|
});
|
||||||
|
@ -44,7 +44,7 @@ impl backend::Backend for Backend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_input(&mut self, _input_request: backend::InputRequest) {
|
fn prepare_input(&mut self, _input_request: backend::InputRequest) {
|
||||||
self.inner_sender.send(Some(Event::Exit));
|
self.inner_sender.send(Some(Event::Exit)).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start_input_thread(
|
fn start_input_thread(
|
||||||
@ -56,8 +56,12 @@ impl backend::Backend for Backend {
|
|||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
for _ in input_requests {
|
for _ in input_requests {
|
||||||
match receiver.recv() {
|
match receiver.recv() {
|
||||||
None => return,
|
Err(_) => return,
|
||||||
Some(event) => event_sink.send(event),
|
Ok(event) => {
|
||||||
|
if event_sink.send(event).is_err() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -33,21 +33,21 @@ pub fn start_resize_thread(
|
|||||||
needs_resize.store(true, Ordering::Relaxed);
|
needs_resize.store(true, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
|
|
||||||
resize_sender.send(Some(Event::WindowResize));
|
resize_sender.send(Some(Event::WindowResize)).unwrap();
|
||||||
// We've sent the message.
|
// We've sent the message.
|
||||||
// This means Cursive was listening, and will now soon be sending a new request.
|
// This means Cursive was listening, and will now soon be sending a new request.
|
||||||
// This means the input thread accepted a request, but hasn't sent a message yet.
|
// This means the input thread accepted a request, but hasn't sent a message yet.
|
||||||
// So we KNOW the input thread is not waiting for a new request.
|
// So we KNOW the input thread is not waiting for a new request.
|
||||||
|
|
||||||
// We sent an event for free, so pay for it now by consuming a request
|
// We sent an event for free, so pay for it now by consuming a request
|
||||||
while let Some(InputRequest::Peek) = resize_requests.recv() {
|
while let Ok(InputRequest::Peek) = resize_requests.recv() {
|
||||||
// At this point Cursive will now listen for input.
|
// At this point Cursive will now listen for input.
|
||||||
// There is a chance the input thread will send his event before us.
|
// There is a chance the input thread will send his event before us.
|
||||||
// But without some extra atomic flag, it'd be hard to know.
|
// But without some extra atomic flag, it'd be hard to know.
|
||||||
// So instead, keep sending `None`
|
// So instead, keep sending `None`
|
||||||
|
|
||||||
// Repeat until we receive a blocking call
|
// Repeat until we receive a blocking call
|
||||||
resize_sender.send(None);
|
resize_sender.send(None).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,10 @@ impl InputParser {
|
|||||||
for _ in request_receiver {
|
for _ in request_receiver {
|
||||||
let event: Result<TEvent, ::std::io::Error> =
|
let event: Result<TEvent, ::std::io::Error> =
|
||||||
events.next().unwrap();
|
events.next().unwrap();
|
||||||
input_sender.send(event.unwrap());
|
|
||||||
|
if input_sender.send(event.unwrap()).is_err() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -78,7 +81,7 @@ impl InputParser {
|
|||||||
/// If we were already expecting input, this is a NO-OP.
|
/// If we were already expecting input, this is a NO-OP.
|
||||||
fn request(&mut self) {
|
fn request(&mut self) {
|
||||||
if !self.event_due {
|
if !self.event_due {
|
||||||
self.requests.send(());
|
self.requests.send(()).unwrap();
|
||||||
self.event_due = true;
|
self.event_due = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,10 +92,10 @@ impl InputParser {
|
|||||||
let timeout = ::std::time::Duration::from_millis(10);
|
let timeout = ::std::time::Duration::from_millis(10);
|
||||||
|
|
||||||
let input = select! {
|
let input = select! {
|
||||||
recv(self.input, input) => {
|
recv(self.input) -> input => {
|
||||||
input
|
input
|
||||||
}
|
}
|
||||||
recv(crossbeam_channel::after(timeout)) => return None,
|
recv(crossbeam_channel::after(timeout)) -> _ => return None,
|
||||||
};
|
};
|
||||||
|
|
||||||
// We got what we came for.
|
// We got what we came for.
|
||||||
@ -316,10 +319,10 @@ impl backend::Backend for Backend {
|
|||||||
for req in input_request {
|
for req in input_request {
|
||||||
match req {
|
match req {
|
||||||
backend::InputRequest::Peek => {
|
backend::InputRequest::Peek => {
|
||||||
event_sink.send(parser.peek());
|
event_sink.send(parser.peek()).unwrap();
|
||||||
}
|
}
|
||||||
backend::InputRequest::Block => {
|
backend::InputRequest::Block => {
|
||||||
event_sink.send(Some(parser.next_event()));
|
event_sink.send(Some(parser.next_event())).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,10 +87,7 @@ impl Default for Cursive {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(not(feature = "termion-backend"), feature = "pancurses-backend"))]
|
||||||
not(feature = "termion-backend"),
|
|
||||||
feature = "pancurses-backend"
|
|
||||||
))]
|
|
||||||
impl Default for Cursive {
|
impl Default for Cursive {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::pancurses()
|
Self::pancurses()
|
||||||
@ -206,7 +203,7 @@ impl Cursive {
|
|||||||
/// siv.set_fps(10);
|
/// siv.set_fps(10);
|
||||||
///
|
///
|
||||||
/// // quit() will be called during the next event cycle
|
/// // quit() will be called during the next event cycle
|
||||||
/// siv.cb_sink().send(Box::new(|s: &mut Cursive| s.quit()));
|
/// siv.cb_sink().send(Box::new(|s: &mut Cursive| s.quit())).unwrap();
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
@ -607,7 +604,7 @@ impl Cursive {
|
|||||||
select! {
|
select! {
|
||||||
// Skip to input if nothing is ready
|
// Skip to input if nothing is ready
|
||||||
default => (),
|
default => (),
|
||||||
recv(self.cb_source, cb) => return Some(Interruption::Callback(cb.unwrap())),
|
recv(self.cb_source) -> cb => return Some(Interruption::Callback(cb.unwrap())),
|
||||||
}
|
}
|
||||||
|
|
||||||
// No callback? Check input then
|
// No callback? Check input then
|
||||||
@ -616,8 +613,11 @@ impl Cursive {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.input_trigger.send(backend::InputRequest::Peek);
|
self.input_trigger
|
||||||
|
.send(backend::InputRequest::Peek)
|
||||||
|
.unwrap();
|
||||||
self.backend.prepare_input(backend::InputRequest::Peek);
|
self.backend.prepare_input(backend::InputRequest::Peek);
|
||||||
|
|
||||||
self.event_source.recv().unwrap().map(Interruption::Event)
|
self.event_source.recv().unwrap().map(Interruption::Event)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,7 +626,9 @@ impl Cursive {
|
|||||||
/// If `peek` is `true`, return `None` immediately if nothing is ready.
|
/// If `peek` is `true`, return `None` immediately if nothing is ready.
|
||||||
fn poll(&mut self) -> Option<Interruption> {
|
fn poll(&mut self) -> Option<Interruption> {
|
||||||
if !self.expecting_event {
|
if !self.expecting_event {
|
||||||
self.input_trigger.send(backend::InputRequest::Block);
|
self.input_trigger
|
||||||
|
.send(backend::InputRequest::Block)
|
||||||
|
.unwrap();
|
||||||
self.backend.prepare_input(backend::InputRequest::Block);
|
self.backend.prepare_input(backend::InputRequest::Block);
|
||||||
self.expecting_event = true;
|
self.expecting_event = true;
|
||||||
}
|
}
|
||||||
@ -639,16 +641,16 @@ impl Cursive {
|
|||||||
};
|
};
|
||||||
|
|
||||||
select! {
|
select! {
|
||||||
recv(self.event_source, event) => {
|
recv(self.event_source) -> event => {
|
||||||
// Ok, we processed the event.
|
// Ok, we processed the event.
|
||||||
self.expecting_event = false;
|
self.expecting_event = false;
|
||||||
|
|
||||||
event.unwrap().map(Interruption::Event)
|
event.unwrap().map(Interruption::Event)
|
||||||
},
|
},
|
||||||
recv(self.cb_source, cb) => {
|
recv(self.cb_source) -> cb => {
|
||||||
cb.map(Interruption::Callback)
|
cb.ok().map(Interruption::Callback)
|
||||||
},
|
},
|
||||||
recv(crossbeam_channel::after(timeout)) => {
|
recv(crossbeam_channel::after(timeout)) -> _ => {
|
||||||
Some(Interruption::Timeout)
|
Some(Interruption::Timeout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user