aboutsummaryrefslogtreecommitdiff
path: root/src/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lisp')
-rw-r--r--src/lisp/expr.rs14
-rw-r--r--src/lisp/prelude.rs15
2 files changed, 23 insertions, 6 deletions
diff --git a/src/lisp/expr.rs b/src/lisp/expr.rs
index 2319601..d2066e7 100644
--- a/src/lisp/expr.rs
+++ b/src/lisp/expr.rs
@@ -1,11 +1,13 @@
1use std::{cmp::PartialEq, convert::TryFrom, fmt}; 1use std::{cmp::PartialEq, convert::TryFrom, fmt};
2 2
3use crate::app::AppState; 3use crate::{
4use crate::lisp::{ 4 app::AppState,
5 error::{EvalError, LispError}, 5 lisp::{
6 eval::lookup, 6 error::{EvalError, LispError},
7 number::LispNumber, 7 eval::lookup,
8 EnvList, 8 number::LispNumber,
9 EnvList,
10 },
9}; 11};
10 12
11#[derive(Debug, Copy, PartialEq, Clone)] 13#[derive(Debug, Copy, PartialEq, Clone)]
diff --git a/src/lisp/prelude.rs b/src/lisp/prelude.rs
index 336dbaf..aebff98 100644
--- a/src/lisp/prelude.rs
+++ b/src/lisp/prelude.rs
@@ -1,6 +1,7 @@
1use crate::{ 1use crate::{
2 bitmap::MapPoint, 2 bitmap::MapPoint,
3 brush::Brush, 3 brush::Brush,
4 guide::Guide,
4 lisp::{ 5 lisp::{
5 error::{EvalError, LispError}, 6 error::{EvalError, LispError},
6 expr::{Arity, LispExpr}, 7 expr::{Arity, LispExpr},
@@ -413,5 +414,19 @@ pub fn new_env() -> Result<Environment, LispError> {
413 return Ok(LispExpr::Unit); 414 return Ok(LispExpr::Unit);
414 }); 415 });
415 416
417 primitive!(env, Arity::Exact(2), "add-guide!", |args, app| {
418 match args {
419 [axis, LispExpr::Number(LispNumber::Integer(offset))] => {
420 let guide = Guide {
421 axis: axis.try_into()?,
422 offset: *offset as u32,
423 };
424 app.guides.insert(guide, true);
425 return Ok(LispExpr::Unit);
426 }
427 _ => return Err(EvalError::TypeMismatch.into()),
428 }
429 });
430
416 Ok(env) 431 Ok(env)
417} 432}