diff options
Diffstat (limited to 'src/lisp/prelude.rs')
-rw-r--r-- | src/lisp/prelude.rs | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/lisp/prelude.rs b/src/lisp/prelude.rs index e24ade5..1d37a32 100644 --- a/src/lisp/prelude.rs +++ b/src/lisp/prelude.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use crate::{ | 1 | use crate::{ |
2 | bitmap::MapPoint, | 2 | bitmap::MapPoint, |
3 | brush::Brush, | 3 | brush::{Brush, RectSelectBrush}, |
4 | grid::GridKind, | 4 | grid::GridKind, |
5 | guide::Guide, | 5 | guide::Guide, |
6 | lisp::{ | 6 | lisp::{ |
@@ -11,7 +11,7 @@ use crate::{ | |||
11 | }, | 11 | }, |
12 | primitive, | 12 | primitive, |
13 | undo::PaintRecord, | 13 | undo::PaintRecord, |
14 | utils::load_script, | 14 | utils::{load_script, rect_coords}, |
15 | }; | 15 | }; |
16 | 16 | ||
17 | use std::convert::TryInto; | 17 | use std::convert::TryInto; |
@@ -437,6 +437,40 @@ pub fn new_env() -> Result<Environment, LispError> { | |||
437 | } | 437 | } |
438 | }); | 438 | }); |
439 | 439 | ||
440 | primitive!(env, Arity::Exact(0), "selection-start", |_, app| { | ||
441 | if let Brush::RectSelect(RectSelectBrush { | ||
442 | start: Some(s), | ||
443 | end: Some(e), | ||
444 | .. | ||
445 | }) = app.brush | ||
446 | { | ||
447 | let pt = rect_coords(s, e).0; | ||
448 | Ok(LispExpr::DottedList(vec![ | ||
449 | (pt.x as i64).into(), | ||
450 | (pt.y as i64).into(), | ||
451 | ])) | ||
452 | } else { | ||
453 | Err(EvalError::CustomInternal("No active selection!").into()) | ||
454 | } | ||
455 | }); | ||
456 | |||
457 | primitive!(env, Arity::Exact(0), "selection-end", |_, app| { | ||
458 | if let Brush::RectSelect(RectSelectBrush { | ||
459 | start: Some(s), | ||
460 | end: Some(e), | ||
461 | .. | ||
462 | }) = app.brush | ||
463 | { | ||
464 | let pt = rect_coords(s, e).1; | ||
465 | Ok(LispExpr::DottedList(vec![ | ||
466 | (pt.x as i64).into(), | ||
467 | (pt.y as i64).into(), | ||
468 | ])) | ||
469 | } else { | ||
470 | Err(EvalError::CustomInternal("No active selection!").into()) | ||
471 | } | ||
472 | }); | ||
473 | |||
440 | primitive!(env, Arity::Exact(2), "range", |args, _| { | 474 | primitive!(env, Arity::Exact(2), "range", |args, _| { |
441 | if type_match!( | 475 | if type_match!( |
442 | args, | 476 | args, |