From 770beedb4466c02a8dc34fc0e1ef2af7bb421331 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Sat, 11 Feb 2023 12:01:52 -0330 Subject: constants --- src/input.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/input.rs') diff --git a/src/input.rs b/src/input.rs index 2f9d820..462e43c 100644 --- a/src/input.rs +++ b/src/input.rs @@ -1,6 +1,6 @@ use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; -use crate::{Calculator, Function, Operator, Signal}; +use crate::{Calculator, Constant, Function, Operator, Signal}; impl Calculator { pub fn handle_input(&mut self, key: KeyEvent) -> Signal { @@ -32,6 +32,8 @@ impl Calculator { if let Some(st) = self.stack.pop() { self.stack.push(func.call_on(st)); } + } else if let Ok(c) = Constant::parse(&self.input_buffer) { + self.stack.push(c.value()); } else if let Ok(bu) = self.input_buffer.parse::() { self.stack.push(bu); } -- cgit v1.2.3