diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2023-02-11 12:01:52 -0330 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2023-02-11 12:01:52 -0330 |
| commit | 770beedb4466c02a8dc34fc0e1ef2af7bb421331 (patch) | |
| tree | 36c04927de1817d70b6b1ee3c5f44ee7122f1011 /src/input.rs | |
| parent | 275bea0c626fa3e62aed714225603d51c4141151 (diff) | |
| download | pfc-770beedb4466c02a8dc34fc0e1ef2af7bb421331.zip | |
constants
Diffstat (limited to 'src/input.rs')
| -rw-r--r-- | src/input.rs | 4 |
1 files changed, 3 insertions, 1 deletions
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::<f64>() { self.stack.push(bu); } |