From c4354e2d8d51cc9fc12dce9ad2d5736e400a8de4 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 4 Apr 2021 15:39:17 +0530 Subject: basic support for adding guides --- src/lisp/expr.rs | 14 ++++++++------ src/lisp/prelude.rs | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'src/lisp') 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 @@ use std::{cmp::PartialEq, convert::TryFrom, fmt}; -use crate::app::AppState; -use crate::lisp::{ - error::{EvalError, LispError}, - eval::lookup, - number::LispNumber, - EnvList, +use crate::{ + app::AppState, + lisp::{ + error::{EvalError, LispError}, + eval::lookup, + number::LispNumber, + EnvList, + }, }; #[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 @@ use crate::{ bitmap::MapPoint, brush::Brush, + guide::Guide, lisp::{ error::{EvalError, LispError}, expr::{Arity, LispExpr}, @@ -413,5 +414,19 @@ pub fn new_env() -> Result { return Ok(LispExpr::Unit); }); + primitive!(env, Arity::Exact(2), "add-guide!", |args, app| { + match args { + [axis, LispExpr::Number(LispNumber::Integer(offset))] => { + let guide = Guide { + axis: axis.try_into()?, + offset: *offset as u32, + }; + app.guides.insert(guide, true); + return Ok(LispExpr::Unit); + } + _ => return Err(EvalError::TypeMismatch.into()), + } + }); + Ok(env) } -- cgit v1.2.3