From 9e804fd1057e45587bcaba49947a86461563b6be Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Wed, 5 Aug 2020 17:19:37 -0700 Subject: [PATCH] Add pause example --- examples/src/bin/pause.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 examples/src/bin/pause.rs diff --git a/examples/src/bin/pause.rs b/examples/src/bin/pause.rs new file mode 100644 index 0000000..a3093a1 --- /dev/null +++ b/examples/src/bin/pause.rs @@ -0,0 +1,27 @@ +use cursive::{self, views}; + +fn main() { + let mut siv = cursive::default(); + + siv.add_layer( + views::Dialog::text("Please write your message.") + .button("Ok", |s| s.quit()), + ); + + siv.run(); + // At this point the terminal is cleaned up. + // We can write to stdout like any CLI program. + // You could also start $EDITOR, or run other commands. + + println!("Enter your message here:"); + + let mut line = String::new(); + std::io::stdin().read_line(&mut line).unwrap(); + + // And we can start another event loop later on. + siv.add_layer( + views::Dialog::text(format!("Your message was:\n{}", line)) + .button("I guess?", |s| s.quit()), + ); + siv.run(); +}