diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lisp/prelude.rs | 17 |
1 files changed, 17 insertions, 0 deletions
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<Environment, LispError> { | |||
524 | } | 524 | } |
525 | }); | 525 | }); |
526 | 526 | ||
527 | primitive!(env, Arity::Exact(0), "mouse", |_, app| { | ||
528 | let (mouse_x, mouse_y) = if let Some((x, y)) = app.idx_at_coord(app.mouse) { | ||
529 | (x + 1, y + 1) | ||
530 | } else { | ||
531 | (0, 0) | ||
532 | }; | ||
533 | Ok(LispExpr::DottedList(vec![ | ||
534 | (mouse_x as i64).into(), | ||
535 | (mouse_y as i64).into(), | ||
536 | ])) | ||
537 | }); | ||
538 | |||
527 | primitive!(env, Arity::Exact(2), "range", |args, _| { | 539 | primitive!(env, Arity::Exact(2), "range", |args, _| { |
528 | if type_match!( | 540 | if type_match!( |
529 | args, | 541 | args, |
@@ -546,5 +558,10 @@ pub fn new_env() -> Result<Environment, LispError> { | |||
546 | Ok(args[0].clone()) | 558 | Ok(args[0].clone()) |
547 | }); | 559 | }); |
548 | 560 | ||
561 | primitive!(env, Arity::Exact(0), "center-mouse", |_, app| { | ||
562 | app.center_mouse(); | ||
563 | Ok(LispExpr::Unit) | ||
564 | }); | ||
565 | |||
549 | Ok(env) | 566 | Ok(env) |
550 | } | 567 | } |