diff options
author | Akshay <[email protected]> | 2021-04-04 11:09:17 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2021-04-04 14:07:09 +0100 |
commit | c4354e2d8d51cc9fc12dce9ad2d5736e400a8de4 (patch) | |
tree | a651a7d2406886869be693baa7afbd7807fdfa0f /src/lisp | |
parent | 62d9de6a368a50dcb62b2b97a5fb02a3858b0977 (diff) |
basic support for adding guides
Diffstat (limited to 'src/lisp')
-rw-r--r-- | src/lisp/expr.rs | 14 | ||||
-rw-r--r-- | src/lisp/prelude.rs | 15 |
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 @@ | |||
1 | use std::{cmp::PartialEq, convert::TryFrom, fmt}; | 1 | use std::{cmp::PartialEq, convert::TryFrom, fmt}; |
2 | 2 | ||
3 | use crate::app::AppState; | 3 | use crate::{ |
4 | use 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 @@ | |||
1 | use crate::{ | 1 | use 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 | } |