Skip to content

Commit

Permalink
Since performance doesn't matter here, always update widget state
Browse files Browse the repository at this point in the history
It shows that we really want to just have persistent widgets to keep
their own state, but then... we can't share the application state
anymore. Maybe that was never the best idea...
  • Loading branch information
Sebastian Thiel committed Jun 4, 2019
1 parent 156c842 commit 1d27826
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/interactive/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ enum CursorDirection {
}

impl TerminalApp {
fn draw<B>(&mut self, terminal: &mut Terminal<B>, do_update: bool) -> Result<(), Error>
fn draw<B>(&mut self, terminal: &mut Terminal<B>) -> Result<(), Error>
where
B: Backend,
{
Expand All @@ -81,16 +81,14 @@ impl TerminalApp {

terminal.draw(|mut f| {
let full_screen = f.size();
let mut window = MainWindow {
MainWindow {
traversal,
display: *display,
state: &state,
widgets,
};
if do_update {
window.update();
}
window.render(&mut f, full_screen)
.update()
.render(&mut f, full_screen)
})?;

Ok(())
Expand All @@ -106,7 +104,7 @@ impl TerminalApp {
{
use termion::event::Key::{Char, Ctrl};

self.draw(terminal, false)?;
self.draw(terminal)?;
for key in keys.filter_map(Result::ok) {
match key {
Char('O') => self.open_that(),
Expand All @@ -120,7 +118,7 @@ impl TerminalApp {
Ctrl('c') | Char('q') => break,
_ => {}
};
self.draw(terminal, true)?;
self.draw(terminal)?;
}
Ok(WalkResult {
num_errors: self.traversal.io_errors,
Expand Down

0 comments on commit 1d27826

Please sign in to comment.