From 59a236d70b9bdd4d18ee95fb6890727c42f17194 Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Mon, 13 Mar 2023 20:30:19 -0230 Subject: degree and radian modes --- src/input.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/input.rs') diff --git a/src/input.rs b/src/input.rs index f1431c5..dbfe763 100644 --- a/src/input.rs +++ b/src/input.rs @@ -20,6 +20,9 @@ impl Calculator { self.input_buffer = String::new(); } KeyCode::Char('C') => self.clear(), + KeyCode::Char('A') => { + self.angle_mode = self.angle_mode.toggle(); + } _ => {} }, KeyModifiers::NONE => match key.code { @@ -29,9 +32,7 @@ impl Calculator { } KeyCode::Enter => { if let Ok(func) = Function::parse(&self.input_buffer) { - if let Some(st) = self.stack.pop() { - self.stack.push(func.call_on(st)); - } + self.call_function(func); } else if let Ok(c) = Constant::parse(&self.input_buffer) { self.stack.push(c.value()); } else if let Ok(bu) = self.input_buffer.parse::() { -- cgit v1.2.3