From 96120e602f43e225d22af6ec1053ebc6797a79f7 Mon Sep 17 00:00:00 2001 From: Akshay Date: Wed, 24 Mar 2021 18:24:39 +0530 Subject: new quit primitive --- src/app.rs | 7 +++++-- src/lisp/eval.rs | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/app.rs b/src/app.rs index 008b273..d35febf 100644 --- a/src/app.rs +++ b/src/app.rs @@ -470,6 +470,11 @@ impl<'ctx> AppState<'ctx> { self.draw(); self.canvas.present(); } + + pub fn quit(&mut self) { + let ev = self.context.event().unwrap(); + ev.push_event(Event::Quit { timestamp: 0u32 }); + } } // publicly available functions on appstate @@ -606,8 +611,6 @@ impl<'ctx> AppState<'ctx> { } } Keycode::V => self.cycle_symmetry(), - // exit - Keycode::Escape => break 'running, // undo & redo Keycode::U => { if let Some(op) = self.undo_stack.undo() { diff --git a/src/lisp/eval.rs b/src/lisp/eval.rs index 63c963c..8bfa86b 100644 --- a/src/lisp/eval.rs +++ b/src/lisp/eval.rs @@ -115,6 +115,10 @@ pub fn with_prelude() -> Environment { Ok(LispExpr::Number(acc)) } }); + primitive!(env, Some(0), "quit", |_, app| { + app.quit(); + Ok(LispExpr::Unit) + }); env } -- cgit v1.2.3