aboutsummaryrefslogtreecommitdiff
path: root/src/gui/message.rs
diff options
context:
space:
mode:
authorJoris2022-02-13 12:17:00 +0100
committerJoris2022-02-13 12:17:00 +0100
commit8a29f30fb2a949c03b318c4f7699136a8001be37 (patch)
tree51decc33aa776201bc800dc2196bc4f8b72337d7 /src/gui/message.rs
parent8170fb5e432cc81986479a6a3a400e009426d76a (diff)
Synchronize deck only if necessary
Look at the modification time of the deck, and synchronize if it has been modified after the last deck read.
Diffstat (limited to 'src/gui/message.rs')
-rw-r--r--src/gui/message.rs21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/gui/message.rs b/src/gui/message.rs
index 01d124e..28a1d2c 100644
--- a/src/gui/message.rs
+++ b/src/gui/message.rs
@@ -12,8 +12,9 @@ use tui::{
pub fn show<B: Backend>(
terminal: &mut Terminal<B>,
events: &Events,
- title: &String,
- message: &String,
+ title: &str,
+ message: &str,
+ wait: bool,
) -> Result<()> {
loop {
terminal.draw(|f| {
@@ -26,16 +27,22 @@ pub fn show<B: Backend>(
let d1 = util::title(title);
f.render_widget(d1, chunks[0]);
- let message = Paragraph::new(util::center_vertically(chunks[1], &message))
+ let message = Paragraph::new(util::center_vertically(chunks[1], &message.to_string()))
.alignment(Alignment::Center);
f.render_widget(message, chunks[1]);
})?;
- if let Event::Input(key) = events.next()? {
- match key {
- Key::Char('q') => return Ok(()),
- _ => (),
+ if wait {
+ if let Event::Input(key) = events.next()? {
+ match key {
+ Key::Char('q') => break,
+ _ => (),
+ }
}
+ } else {
+ break;
}
}
+
+ Ok(())
}