Skip to content

Commit

Permalink
Fix rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Mroik committed May 7, 2024
1 parent 16fb468 commit 0ce8fb9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
19 changes: 11 additions & 8 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@ impl App {
}

fn render(&mut self) {
self.renderer.render_fitch(&self.model, &self.info_text());
match self.state {
State::Noraml => (),
State::AddAssumption => self
.renderer
.render_expression_box("Assumption expression", &self.expression_buffer),
_ => (),
}
let (title, render_box) = match self.state {
State::AddAssumption => ("Assumption expression", true),
_ => ("", false),
};
self.renderer.render_fitch(
&self.model,
&self.info_text(),
title,
&self.expression_buffer,
render_box,
);
}

pub fn listen(&mut self) {
Expand Down
20 changes: 13 additions & 7 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ impl Renderer {
Ok(renderer)
}

pub fn render_fitch(&mut self, model: &Fitch, info: &str) {
pub fn render_fitch(
&mut self,
model: &Fitch,
info: &str,
title: &str,
buffer: &str,
render_box: bool,
) {
self.terminal
.draw(|frame| {
let (f_a, i_a) = base_area(frame.size());
Expand All @@ -43,13 +50,12 @@ impl Renderer {

frame.render_widget(fitch_widget, f_a);
frame.render_widget(info_widget, i_a);
})
.unwrap();
}

pub fn render_expression_box(&mut self, title: &str, buffer: &str) {
self.terminal
.draw(|frame| {
if !render_box {
return;
}

// Render expression BOX
let area = expression_box_area(frame.size());
let expression_widget = Paragraph::new(buffer).block(
Block::default()
Expand Down

0 comments on commit 0ce8fb9

Please sign in to comment.