From 41c50e4c324b19183d1c36c185878d4fa500662a Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 9 May 2021 10:24:03 +0530 Subject: new `mouse` and `center-mouse` lisp primitives --- src/lisp/prelude.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lisp/prelude.rs b/src/lisp/prelude.rs index 9330372..dddce5f 100644 --- a/src/lisp/prelude.rs +++ b/src/lisp/prelude.rs @@ -524,6 +524,18 @@ pub fn new_env() -> Result { } }); + primitive!(env, Arity::Exact(0), "mouse", |_, app| { + let (mouse_x, mouse_y) = if let Some((x, y)) = app.idx_at_coord(app.mouse) { + (x + 1, y + 1) + } else { + (0, 0) + }; + Ok(LispExpr::DottedList(vec![ + (mouse_x as i64).into(), + (mouse_y as i64).into(), + ])) + }); + primitive!(env, Arity::Exact(2), "range", |args, _| { if type_match!( args, @@ -546,5 +558,10 @@ pub fn new_env() -> Result { Ok(args[0].clone()) }); + primitive!(env, Arity::Exact(0), "center-mouse", |_, app| { + app.center_mouse(); + Ok(LispExpr::Unit) + }); + Ok(env) } -- cgit v1.2.3