mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-27 11:16:03 +00:00
Add pause example
This commit is contained in:
parent
76170ab2dd
commit
9e804fd105
27
examples/src/bin/pause.rs
Normal file
27
examples/src/bin/pause.rs
Normal file
@ -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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user