cargo-fmt, version update
This commit is contained in:
parent
f41d3dd55a
commit
b49d93dc96
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "neovim-gtk"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
authors = ["daa84 <daa84@inbox.ru>"]
|
||||
build = "build.rs"
|
||||
|
||||
|
@ -25,7 +25,7 @@ fn main() {
|
||||
guard_dispatch_thread(&mut *ui);
|
||||
});
|
||||
|
||||
gtk::main();
|
||||
gtk::main();
|
||||
}
|
||||
|
||||
fn guard_dispatch_thread(ui: &mut ui::Ui) {
|
||||
|
41
src/nvim.rs
41
src/nvim.rs
@ -75,7 +75,7 @@ pub fn initialize(ui: &mut Ui) -> Result<()> {
|
||||
nvim.session.start_event_loop_cb(move |m, p| nvim_cb(m, p));
|
||||
// fix neovim --embed bug to start embed mode
|
||||
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(())
|
||||
}
|
||||
@ -139,21 +139,11 @@ fn call(method: &str, args: Vec<Value>) {
|
||||
safe_call(move |ui| {
|
||||
if let Value::Map(ref attrs) = args[0] {
|
||||
let attrs_map: HashMap<String, Value> = attrs.iter()
|
||||
.map(|v| {
|
||||
match v {
|
||||
&(Value::String(ref key),
|
||||
ref value) => {
|
||||
(key.clone(),
|
||||
value.clone())
|
||||
}
|
||||
_ => {
|
||||
panic!("attribute \
|
||||
key must be \
|
||||
string")
|
||||
}
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
.map(|v| match v {
|
||||
&(Value::String(ref key), ref value) => (key.clone(), value.clone()),
|
||||
_ => panic!("attribute key must be string"),
|
||||
})
|
||||
.collect();
|
||||
ui.on_highlight_set(&attrs_map);
|
||||
} else {
|
||||
panic!("Supports only map value as argument");
|
||||
@ -168,25 +158,28 @@ fn call(method: &str, args: Vec<Value>) {
|
||||
})
|
||||
}
|
||||
"set_scroll_region" => {
|
||||
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]));
|
||||
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]));
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
"scroll" => {
|
||||
safe_call(move |ui| {
|
||||
safe_call(move |ui| {
|
||||
ui.on_scroll(try_int!(args[0]));
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
"update_bg" => {
|
||||
safe_call(move |ui| {
|
||||
safe_call(move |ui| {
|
||||
ui.on_update_bg(try_int!(args[0]));
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
"update_fg" => {
|
||||
safe_call(move |ui| {
|
||||
safe_call(move |ui| {
|
||||
ui.on_update_fg(try_int!(args[0]));
|
||||
Ok(())
|
||||
});
|
||||
@ -217,10 +210,8 @@ fn safe_call<F>(cb: F)
|
||||
where F: Fn(&mut Ui) -> result::Result<(), String> + 'static + Send
|
||||
{
|
||||
glib::idle_add(move || {
|
||||
ui::UI.with(|ui_cell| {
|
||||
if let Err(msg) = cb(&mut *ui_cell.borrow_mut()) {
|
||||
println!("Error call function: {}", msg);
|
||||
}
|
||||
ui::UI.with(|ui_cell| if let Err(msg) = cb(&mut *ui_cell.borrow_mut()) {
|
||||
println!("Error call function: {}", msg);
|
||||
});
|
||||
glib::Continue(false)
|
||||
});
|
||||
|
@ -116,7 +116,7 @@ impl Ui {
|
||||
self.drawing_area
|
||||
.set_events((gdk_sys::GDK_BUTTON_RELEASE_MASK | gdk_sys::GDK_BUTTON_PRESS_MASK |
|
||||
gdk_sys::GDK_BUTTON_MOTION_MASK)
|
||||
.bits() as i32);
|
||||
.bits() as i32);
|
||||
self.drawing_area.connect_button_press_event(gtk_button_press);
|
||||
self.drawing_area.connect_button_release_event(gtk_button_release);
|
||||
self.drawing_area.connect_motion_notify_event(gtk_motion_notify);
|
||||
|
@ -119,10 +119,10 @@ impl UiModel {
|
||||
|
||||
fn copy_row(&mut self, row: usize, offset: i64, left: usize, right: usize) {
|
||||
for col in left..right + 1 {
|
||||
let from_row = (row as i64 + offset) as usize;
|
||||
let from_cell = self.model[from_row][col].clone();
|
||||
self.model[row][col] = from_cell;
|
||||
}
|
||||
let from_row = (row as i64 + offset) as usize;
|
||||
let from_cell = self.model[from_row][col].clone();
|
||||
self.model[row][col] = from_cell;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scroll(&mut self, count: i64) {
|
||||
|
Loading…
Reference in New Issue
Block a user