2016-06-28 08:10:48 +00:00
|
|
|
extern crate cursive;
|
|
|
|
|
2016-07-21 04:25:14 +00:00
|
|
|
use cursive::prelude::*;
|
2016-06-28 08:10:48 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
|
|
|
let mut siv = Cursive::new();
|
|
|
|
|
2016-07-02 22:02:42 +00:00
|
|
|
siv.menubar()
|
|
|
|
.add("File",
|
|
|
|
MenuTree::new()
|
|
|
|
.leaf("New", |s| s.add_layer(Dialog::info("New file!")))
|
2016-07-03 03:44:27 +00:00
|
|
|
.subtree("Recent", MenuTree::new().with(|tree| {
|
2016-07-03 03:53:13 +00:00
|
|
|
for i in 1..100 {
|
2016-07-03 03:44:27 +00:00
|
|
|
tree.add_leaf(&format!("Item {}", i), |_| ())
|
|
|
|
}
|
|
|
|
}))
|
2016-07-03 02:37:38 +00:00
|
|
|
.delimiter()
|
2016-07-03 03:44:27 +00:00
|
|
|
.with(|tree| {
|
|
|
|
for i in 1..10 {
|
|
|
|
tree.add_leaf(&format!("Option {}", i), |_| ());
|
|
|
|
}
|
|
|
|
})
|
2016-07-03 02:37:38 +00:00
|
|
|
.delimiter()
|
2016-07-02 22:02:42 +00:00
|
|
|
.leaf("Quit", |s| s.quit()))
|
|
|
|
.add("Help",
|
|
|
|
MenuTree::new()
|
2016-07-03 02:37:38 +00:00
|
|
|
.subtree("Help",
|
|
|
|
MenuTree::new()
|
|
|
|
.leaf("General", |s| {
|
|
|
|
s.add_layer(Dialog::info("Help message!"))
|
|
|
|
})
|
|
|
|
.leaf("Online", |s| {
|
|
|
|
s.add_layer(Dialog::info("Google it \
|
|
|
|
yourself!\nKids, \
|
|
|
|
these days..."))
|
|
|
|
}))
|
2016-07-02 22:02:42 +00:00
|
|
|
.leaf("About",
|
|
|
|
|s| s.add_layer(Dialog::info("Cursive v0.0.0"))));
|
2016-06-28 08:10:48 +00:00
|
|
|
|
2016-07-02 22:02:42 +00:00
|
|
|
// siv.set_autohide_menu(false);
|
2016-06-28 08:10:48 +00:00
|
|
|
|
2016-07-03 02:37:38 +00:00
|
|
|
siv.add_global_callback(Key::Esc, |s| s.select_menubar());
|
2016-07-02 22:02:42 +00:00
|
|
|
|
2016-07-03 02:37:38 +00:00
|
|
|
siv.add_layer(Dialog::new(TextView::new("Hit <Esc> to show the menu!")));
|
2016-06-28 08:10:48 +00:00
|
|
|
|
|
|
|
siv.run();
|
|
|
|
}
|