neovim-gtk/src/main.rs

41 lines
831 B
Rust
Raw Normal View History

2016-03-16 14:39:53 +00:00
extern crate gtk;
2016-03-31 13:52:22 +00:00
extern crate gdk;
2016-05-05 07:23:04 +00:00
extern crate gdk_sys;
2016-03-28 14:14:10 +00:00
extern crate glib;
2016-04-06 14:53:16 +00:00
extern crate glib_sys;
2016-03-16 14:39:53 +00:00
extern crate cairo;
2016-03-19 10:27:39 +00:00
extern crate neovim_lib;
2016-04-02 20:00:18 +00:00
extern crate phf;
2016-03-16 14:39:53 +00:00
2016-03-19 10:27:39 +00:00
mod nvim;
2016-03-19 08:47:23 +00:00
mod ui_model;
2016-03-16 15:25:25 +00:00
mod ui;
2016-04-04 10:14:57 +00:00
mod input;
2016-03-16 14:39:53 +00:00
2016-05-05 14:27:45 +00:00
use std::thread;
2016-03-16 15:25:25 +00:00
fn main() {
2016-03-31 10:09:34 +00:00
gtk::init().expect("Failed to initialize GTK");
ui::UI.with(|ui_cell| {
let mut ui = ui_cell.borrow_mut();
ui.init();
2016-03-31 10:09:34 +00:00
nvim::initialize(&mut *ui).expect("Can't start nvim instance");
2016-05-05 14:27:45 +00:00
guard_dispatch_thread(&mut *ui);
2016-03-31 10:09:34 +00:00
});
2017-02-26 19:33:44 +00:00
gtk::main();
2016-03-16 14:39:53 +00:00
}
2016-05-05 14:27:45 +00:00
fn guard_dispatch_thread(ui: &mut ui::Ui) {
let guard = ui.nvim().session.take_dispatch_guard();
thread::spawn(move || {
guard.join().expect("Can't join dispatch thread");
glib::idle_add(move || {
gtk::main_quit();
glib::Continue(false)
});
});
}