aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.rs')
-rw-r--r--src/app.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/app.rs b/src/app.rs
index 016349b..eef896d 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -4,7 +4,7 @@ use crate::{
4 command::CommandBox, 4 command::CommandBox,
5 consts::{colors::*, FONT_PATH}, 5 consts::{colors::*, FONT_PATH},
6 dither, 6 dither,
7 lisp::{eval, lex::Lexer, parse::Parser, prelude, EnvList}, 7 lisp::{error::LispError, eval, lex::Lexer, parse::Parser, prelude, EnvList},
8 message::Message, 8 message::Message,
9 rect, 9 rect,
10 symmetry::Symmetry, 10 symmetry::Symmetry,
@@ -284,7 +284,7 @@ impl<'ctx, 'file> AppState<'ctx, 'file> {
284 Ok(val) => self.message.set_info(format!("{}", val)), 284 Ok(val) => self.message.set_info(format!("{}", val)),
285 Err(eval_err) => self.message.set_error(format!("{}", eval_err)), 285 Err(eval_err) => self.message.set_error(format!("{}", eval_err)),
286 }, 286 },
287 Err(parse_err) => self.message.set_error(format!("{}", parse_err)), 287 Err(err) => self.message = AppState::handle_error(err, &lisp_expr),
288 } 288 }
289 self.command_box.hist_append(); 289 self.command_box.hist_append();
290 290
@@ -292,6 +292,15 @@ impl<'ctx, 'file> AppState<'ctx, 'file> {
292 self.mode = Mode::Draw; 292 self.mode = Mode::Draw;
293 } 293 }
294 294
295 fn handle_error(err: LispError, src: &str) -> Message {
296 let mut message = Message::new();
297 match err {
298 LispError::Parse(p) => message.set_error(p.display(&src)),
299 eval_err => message.set_error(eval_err.to_string()),
300 }
301 message
302 }
303
295 fn draw_grid(&mut self) { 304 fn draw_grid(&mut self) {
296 let cs = self.zoom as u32; 305 let cs = self.zoom as u32;
297 let (width, height) = (self.width(), self.height()); 306 let (width, height) = (self.width(), self.height());