aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-05-09 05:54:03 +0100
committerAkshay <[email protected]>2021-05-09 05:54:03 +0100
commit41c50e4c324b19183d1c36c185878d4fa500662a (patch)
tree6227427e126b250505470e7caffbaef5972f4466 /src
parentec5a819b44747b8da54bd69c4453373ea56a5247 (diff)
new `mouse` and `center-mouse` lisp primitives
Diffstat (limited to 'src')
-rw-r--r--src/lisp/prelude.rs17
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}