aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2023-02-01 18:21:39 -0330
committerSam Anthony <sam@samanthony.xyz>2023-02-01 18:21:39 -0330
commit0d6119ab6f06762f650025ccb3dbdb626c445a58 (patch)
tree1f055e57e6809b7d77ee464f2716e75b81708c46
parent1cc1ee92dd74747bef969fa2f5b72277232573cd (diff)
downloadpfc-0d6119ab6f06762f650025ccb3dbdb626c445a58.zip
reverse direction of layout
-rw-r--r--src/main.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index b241afa..f3f3d9a 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -49,7 +49,7 @@ impl App {
self.perform_operation(op);
}
}
- KeyCode::Enter => {
+ KeyCode::Enter if self.input_buffer.len() > 0 => {
self.stack.push(self.input_buffer.parse::<f64>().unwrap());
self.input_buffer = String::new();
}
@@ -66,17 +66,23 @@ impl App {
fn draw<B: Backend>(&self, f: &mut Frame<B>) {
let chunks = Layout::default()
.direction(Direction::Vertical)
- .constraints([Constraint::Length(1), Constraint::Percentage(100)].as_ref())
+ .constraints(
+ [
+ Constraint::Max(u16::MAX),
+ Constraint::Length(self.stack.len() as u16),
+ Constraint::Length(1),
+ ]
+ .as_ref(),
+ )
.split(f.size());
- f.render_widget(Paragraph::new(self.input_buffer.as_str()), chunks[0]);
-
let items: Vec<ListItem> = (self.stack)
.iter()
- .rev()
.map(|f| ListItem::new(format!("{}", f)))
.collect();
f.render_widget(List::new(items), chunks[1]);
+
+ f.render_widget(Paragraph::new(self.input_buffer.as_str()), chunks[2]);
}
fn perform_operation(&mut self, op: Operator) {