diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2023-04-03 10:40:51 -0230 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2023-04-03 10:40:51 -0230 |
| commit | eb3dd36c4229241aad610b8ed812cc12d8f87c2b (patch) | |
| tree | 6468185ae8757cea36a6ae2390eee6e6fcba3073 /src/input.rs | |
| parent | 60801d22ec9c72eb1ec442e81728fad524b1df2b (diff) | |
| download | pfc-0.8.0.zip | |
negationv0.8.0
Diffstat (limited to 'src/input.rs')
| -rw-r--r-- | src/input.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/input.rs b/src/input.rs index 4de615f..2d982e5 100644 --- a/src/input.rs +++ b/src/input.rs @@ -23,6 +23,15 @@ impl Calculator { KeyCode::Char('A') => { self.angle_mode = self.angle_mode.toggle(); } + KeyCode::Char('N') => { + if self.input_buffer.len() > 0 { + if let Ok(f) = self.input_buffer.parse::<f64>() { + self.input_buffer = format!("{}", -f); + } + } else if let Some(v) = self.stack.pop() { + self.stack.push(-v); + } + } _ => {} }, KeyModifiers::NONE => match key.code { |