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 | |
| parent | 60801d22ec9c72eb1ec442e81728fad524b1df2b (diff) | |
| download | pfc-0.8.0.zip | |
negationv0.8.0
| -rw-r--r-- | Cargo.lock | 2 | ||||
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | config.mk | 2 | ||||
| -rw-r--r-- | pfc.1 | 3 | ||||
| -rw-r--r-- | src/input.rs | 9 |
5 files changed, 15 insertions, 3 deletions
@@ -113,7 +113,7 @@ dependencies = [ [[package]] name = "pfc" -version = "0.7.0" +version = "0.8.0" dependencies = [ "crossterm", "tui", @@ -1,6 +1,6 @@ [package] name = "pfc" -version = "0.7.0" +version = "0.8.0" edition = "2021" [dependencies] @@ -1,4 +1,4 @@ -VERSION = 0.7 +VERSION = 0.8 PREFIX = /usr/local MANPREFIX = ${PREFIX}/share/man @@ -40,6 +40,9 @@ Delete the contents of the input buffer and the stack. .TP .B Shift-a Toggle between degree and radian mode. +.TP +.B Shift-n +Negation. If there is a number in the buffer, negate it. Otherwise, negate the bottom number in the stack. .SS Operators .TP .B + 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 { |