cargo-fmt, version update

This commit is contained in:
daa 2017-02-26 22:33:44 +03:00
parent f41d3dd55a
commit b49d93dc96
5 changed files with 23 additions and 32 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "neovim-gtk" name = "neovim-gtk"
version = "0.1.0" version = "0.1.1"
authors = ["daa84 <daa84@inbox.ru>"] authors = ["daa84 <daa84@inbox.ru>"]
build = "build.rs" build = "build.rs"

View File

@ -75,7 +75,7 @@ pub fn initialize(ui: &mut Ui) -> Result<()> {
nvim.session.start_event_loop_cb(move |m, p| nvim_cb(m, p)); nvim.session.start_event_loop_cb(move |m, p| nvim_cb(m, p));
// fix neovim --embed bug to start embed mode // fix neovim --embed bug to start embed mode
nvim.input("i").unwrap(); nvim.input("i").unwrap();
try!(nvim.ui_attach(80, 24, true).map_err(|e| Error::new(ErrorKind::Other, e))); nvim.ui_attach(80, 24, true).map_err(|e| Error::new(ErrorKind::Other, e))?;
Ok(()) Ok(())
} }
@ -139,19 +139,9 @@ fn call(method: &str, args: Vec<Value>) {
safe_call(move |ui| { safe_call(move |ui| {
if let Value::Map(ref attrs) = args[0] { if let Value::Map(ref attrs) = args[0] {
let attrs_map: HashMap<String, Value> = attrs.iter() let attrs_map: HashMap<String, Value> = attrs.iter()
.map(|v| { .map(|v| match v {
match v { &(Value::String(ref key), ref value) => (key.clone(), value.clone()),
&(Value::String(ref key), _ => panic!("attribute key must be string"),
ref value) => {
(key.clone(),
value.clone())
}
_ => {
panic!("attribute \
key must be \
string")
}
}
}) })
.collect(); .collect();
ui.on_highlight_set(&attrs_map); ui.on_highlight_set(&attrs_map);
@ -169,7 +159,10 @@ fn call(method: &str, args: Vec<Value>) {
} }
"set_scroll_region" => { "set_scroll_region" => {
safe_call(move |ui| { safe_call(move |ui| {
ui.on_set_scroll_region(try_uint!(args[0]), try_uint!(args[1]), try_uint!(args[2]), try_uint!(args[3])); ui.on_set_scroll_region(try_uint!(args[0]),
try_uint!(args[1]),
try_uint!(args[2]),
try_uint!(args[3]));
Ok(()) Ok(())
}); });
} }
@ -217,10 +210,8 @@ fn safe_call<F>(cb: F)
where F: Fn(&mut Ui) -> result::Result<(), String> + 'static + Send where F: Fn(&mut Ui) -> result::Result<(), String> + 'static + Send
{ {
glib::idle_add(move || { glib::idle_add(move || {
ui::UI.with(|ui_cell| { ui::UI.with(|ui_cell| if let Err(msg) = cb(&mut *ui_cell.borrow_mut()) {
if let Err(msg) = cb(&mut *ui_cell.borrow_mut()) {
println!("Error call function: {}", msg); println!("Error call function: {}", msg);
}
}); });
glib::Continue(false) glib::Continue(false)
}); });