diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2023-03-13 20:30:19 -0230 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2023-03-13 20:30:19 -0230 |
| commit | 59a236d70b9bdd4d18ee95fb6890727c42f17194 (patch) | |
| tree | ae31ca3d583bd442fefe16582ad665470c47cab5 /src/input.rs | |
| parent | 99a8712464793c2120c2bf880e87fbbab65475ad (diff) | |
| download | pfc-59a236d70b9bdd4d18ee95fb6890727c42f17194.zip | |
degree and radian modes
Diffstat (limited to 'src/input.rs')
| -rw-r--r-- | src/input.rs | 7 |
1 files changed, 4 insertions, 3 deletions
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::<f64>() { |