diff --git a/src/backend/blt.rs b/src/backend/blt.rs index 1712f09..fa79051 100644 --- a/src/backend/blt.rs +++ b/src/backend/blt.rs @@ -81,7 +81,7 @@ impl backend::Backend for Concrete { if let Some(ev) = terminal::wait_event() { match ev { // TODO: what should we do here? - BltEvent::Close => Event::Refresh, + BltEvent::Close => Event::Exit, BltEvent::Resize { .. } => Event::WindowResize, // TODO: mouse support BltEvent::MouseMove { .. } => Event::Refresh, diff --git a/src/event.rs b/src/event.rs index 5d5e349..cf3c384 100644 --- a/src/event.rs +++ b/src/event.rs @@ -218,6 +218,10 @@ pub enum Event { /// An unknown event was received. Unknown(i32), + + #[doc(hidden)] + /// The application is about to exit. + Exit, } impl From for Event { diff --git a/src/lib.rs b/src/lib.rs index bfbc333..710320c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -530,6 +530,10 @@ impl Cursive { // Wait for next event. // (If set_fps was called, this returns -1 now and then) let event = self.backend.poll_event(); + if event == Event::Exit { + self.quit(); + } + if event == Event::WindowResize { self.backend.clear(); }