Add Event::Exit

Currently only sent by the bear lib terminal.
This commit is contained in:
Alexandre Bury 2016-10-11 17:47:44 -07:00
parent 4aaee06d9e
commit 65d86f3638
3 changed files with 9 additions and 1 deletions

View File

@ -81,7 +81,7 @@ impl backend::Backend for Concrete {
if let Some(ev) = terminal::wait_event() { if let Some(ev) = terminal::wait_event() {
match ev { match ev {
// TODO: what should we do here? // TODO: what should we do here?
BltEvent::Close => Event::Refresh, BltEvent::Close => Event::Exit,
BltEvent::Resize { .. } => Event::WindowResize, BltEvent::Resize { .. } => Event::WindowResize,
// TODO: mouse support // TODO: mouse support
BltEvent::MouseMove { .. } => Event::Refresh, BltEvent::MouseMove { .. } => Event::Refresh,

View File

@ -218,6 +218,10 @@ pub enum Event {
/// An unknown event was received. /// An unknown event was received.
Unknown(i32), Unknown(i32),
#[doc(hidden)]
/// The application is about to exit.
Exit,
} }
impl From<char> for Event { impl From<char> for Event {

View File

@ -530,6 +530,10 @@ impl Cursive {
// Wait for next event. // Wait for next event.
// (If set_fps was called, this returns -1 now and then) // (If set_fps was called, this returns -1 now and then)
let event = self.backend.poll_event(); let event = self.backend.poll_event();
if event == Event::Exit {
self.quit();
}
if event == Event::WindowResize { if event == Event::WindowResize {
self.backend.clear(); self.backend.clear();
} }