2016-06-28 08:10:48 +00:00
|
|
|
extern crate cursive;
|
|
|
|
|
|
|
|
use cursive::Cursive;
|
2016-07-02 22:02:42 +00:00
|
|
|
use cursive::menu::MenuTree;
|
2016-06-28 08:10:48 +00:00
|
|
|
use cursive::view::Dialog;
|
2016-07-02 22:02:42 +00:00
|
|
|
use cursive::view::TextView;
|
2016-06-28 08:10:48 +00:00
|
|
|
use cursive::event::Key;
|
|
|
|
|
|
|
|
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!")))
|
|
|
|
.leaf("Quit", |s| s.quit()))
|
|
|
|
.add("Help",
|
|
|
|
MenuTree::new()
|
|
|
|
.leaf("Help", |s| s.add_layer(Dialog::info("Help message!")))
|
|
|
|
.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-02 22:02:42 +00:00
|
|
|
siv.add_global_callback(Key::F(10), |s| s.select_menubar());
|
|
|
|
|
|
|
|
siv.add_layer(Dialog::new(TextView::new("Hit <F10> to show the menu!")));
|
2016-06-28 08:10:48 +00:00
|
|
|
|
|
|
|
siv.run();
|
|
|
|
}
|