maj/majc/src/main.rs

47 lines
1.3 KiB
Rust
Raw Normal View History

use cursive::{event::Key, menu::MenuTree};
pub(crate) mod commands;
pub(crate) mod gemini;
pub(crate) mod theme;
2020-07-27 22:14:45 +00:00
pub(crate) mod tls;
2020-07-25 16:39:10 +00:00
fn main() {
cursive::logger::init();
let mut siv = cursive::default();
theme::apply(&mut siv);
siv.set_user_data(gemini::State::default());
2020-07-25 18:42:51 +00:00
2020-07-25 16:50:34 +00:00
siv.add_global_callback('c', |s| {
s.pop_layer();
});
2020-07-25 16:39:10 +00:00
siv.add_global_callback('q', cursive::Cursive::quit);
siv.add_global_callback('~', cursive::Cursive::toggle_debug_console);
siv.add_global_callback('h', gemini::history);
siv.add_global_callback('l', gemini::links);
siv.add_global_callback('o', gemini::open_prompt);
siv.add_global_callback('?', commands::help);
2020-07-25 16:39:10 +00:00
siv.menubar()
.add_subtree(
"majc",
MenuTree::new()
.leaf("About", commands::about)
2020-07-27 21:31:38 +00:00
.leaf("Changelog", commands::changelog)
.leaf("Help", commands::help)
2020-07-27 20:05:22 +00:00
.leaf("Quit", cursive::Cursive::quit),
2020-07-25 16:39:10 +00:00
)
.add_leaf("Open", gemini::open_prompt)
.add_leaf("Links", gemini::links)
.add_leaf("History", gemini::history);
2020-07-25 16:39:10 +00:00
2020-07-25 16:50:34 +00:00
siv.set_autohide_menu(false);
2020-07-25 16:39:10 +00:00
siv.add_global_callback(Key::Esc, |s| s.select_menubar());
commands::help(&mut siv);
2020-07-25 16:39:10 +00:00
siv.run();
}