Skip to content

Commit 1c01d3a

Browse files
committed
Another round of minor improvements.
- space also adds to the stack (similar to dc) - explicitly show the version in the header - use consistent display of key.
1 parent b3c3c88 commit 1c01d3a

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "helix-calc"
3-
version = "1.0.3"
3+
version = "1.0.4"
44
authors = ["Fred Gobry <[email protected]>"]
55
edition = "2021"
66
description = "Reverse Polish Notation calculator in a terminal app."
@@ -10,6 +10,10 @@ license = "GPL-3.0-only"
1010
keywords = ["tui", "calculator", "rpn"]
1111
categories = ["command-line-utilities"]
1212

13+
[[bin]]
14+
name = "hc"
15+
path = "src/main.rs"
16+
1317
[dependencies]
1418
anyhow = "1"
1519
bigdecimal = "0"

src/hc.rs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl App<'_> {
106106
KeyCode::Char('q') => {
107107
self.exit = true;
108108
}
109-
KeyCode::Enter => {
109+
KeyCode::Enter | KeyCode::Char(' ') => {
110110
self.consume();
111111
}
112112
KeyCode::Char('?') => {
@@ -146,7 +146,7 @@ impl App<'_> {
146146

147147
fn instructions(&self) -> impl Widget {
148148
Line::from(vec![
149-
" Helix Calc - ".into(),
149+
format!(" Helix Calc {} - ", env!("CARGO_PKG_VERSION")).into(),
150150
" Help ".into(),
151151
"< ? > ".blue().bold(),
152152
" Quit ".into(),
@@ -192,17 +192,24 @@ impl App<'_> {
192192

193193
fn status(&self) -> impl Widget {
194194
let status = match &self.op_status {
195-
Ok(_) => Line::from(if self.empty_input() {
196-
if let Some(c) = self.op {
197-
format!("< {} >", c).blue().bold()
195+
Ok(_) => {
196+
if self.empty_input() {
197+
if let Some(c) = self.op {
198+
Line::from(format!("< {} >", c).blue().bold())
199+
} else {
200+
Line::from("")
201+
}
202+
} else if self.value().is_some() {
203+
Line::from(vec![
204+
"< Enter >".bold().blue(),
205+
" or ".into(),
206+
"< Space >".bold().blue(),
207+
" to add to the stack".into(),
208+
])
198209
} else {
199-
"".into()
210+
Line::from("Input is not a valid number")
200211
}
201-
} else if self.value().is_some() {
202-
"<Enter> to add to the stack".into()
203-
} else {
204-
"Input is not a valid number".into()
205-
}),
212+
}
206213
Err(err) => {
207214
if let Some(c) = self.op {
208215
Line::from(vec![

0 commit comments

Comments
 (0)