aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--config.mk2
-rw-r--r--pfc.13
-rw-r--r--src/input.rs9
5 files changed, 15 insertions, 3 deletions
diff --git a/Cargo.lock b/Cargo.lock
index edd14a1..08d4da2 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -113,7 +113,7 @@ dependencies = [
[[package]]
name = "pfc"
-version = "0.7.0"
+version = "0.8.0"
dependencies = [
"crossterm",
"tui",
diff --git a/Cargo.toml b/Cargo.toml
index 61d26cc..8e064b7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pfc"
-version = "0.7.0"
+version = "0.8.0"
edition = "2021"
[dependencies]
diff --git a/config.mk b/config.mk
index d7e1abf..22408f9 100644
--- a/config.mk
+++ b/config.mk
@@ -1,4 +1,4 @@
-VERSION = 0.7
+VERSION = 0.8
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
diff --git a/pfc.1 b/pfc.1
index 348cec2..2ee7c37 100644
--- a/pfc.1
+++ b/pfc.1
@@ -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 {