Apply rustfmt
This commit is contained in:
parent
9967b4bdb4
commit
d30f65c45f
14
src/shell.rs
14
src/shell.rs
@ -33,7 +33,7 @@ use error;
|
||||
use mode;
|
||||
use render;
|
||||
use render::CellMetrics;
|
||||
use subscriptions::{Subscriptions, SubscriptionHandle};
|
||||
use subscriptions::{SubscriptionHandle, Subscriptions};
|
||||
|
||||
const DEFAULT_FONT_NAME: &str = "DejaVu Sans Mono 12";
|
||||
pub const MINIMUM_SUPPORTED_NVIM_VERSION: &str = "0.2.2";
|
||||
@ -338,11 +338,15 @@ impl State {
|
||||
where
|
||||
F: Fn(Vec<String>) + 'static,
|
||||
{
|
||||
self.subscriptions.borrow_mut().subscribe(event_name, args, cb)
|
||||
self.subscriptions
|
||||
.borrow_mut()
|
||||
.subscribe(event_name, args, cb)
|
||||
}
|
||||
|
||||
pub fn set_autocmds(&self) {
|
||||
self.subscriptions.borrow().set_autocmds(&mut self.nvim().unwrap());
|
||||
self.subscriptions
|
||||
.borrow()
|
||||
.set_autocmds(&mut self.nvim().unwrap());
|
||||
}
|
||||
|
||||
pub fn notify(&self, params: Vec<Value>) -> Result<(), String> {
|
||||
@ -350,7 +354,9 @@ impl State {
|
||||
}
|
||||
|
||||
pub fn run_now(&self, handle: &SubscriptionHandle) {
|
||||
self.subscriptions.borrow().run_now(handle, &mut self.nvim().unwrap());
|
||||
self.subscriptions
|
||||
.borrow()
|
||||
.run_now(handle, &mut self.nvim().unwrap());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,15 +89,13 @@ impl Subscriptions {
|
||||
pub fn set_autocmds(&self, nvim: &mut NeovimRef) {
|
||||
for (event_name, subscriptions) in &self.0 {
|
||||
for (i, subscription) in subscriptions.iter().enumerate() {
|
||||
let args = subscription.args
|
||||
let args = subscription
|
||||
.args
|
||||
.iter()
|
||||
.fold("".to_owned(), |acc, arg| acc + ", " + &arg);
|
||||
nvim.command(&format!(
|
||||
"au {} * call rpcnotify(1, 'subscription', '{}', {} {})",
|
||||
event_name,
|
||||
event_name,
|
||||
i,
|
||||
args,
|
||||
event_name, event_name, i, args,
|
||||
)).expect("Could not set autocmd");
|
||||
}
|
||||
}
|
||||
@ -139,14 +137,13 @@ impl Subscriptions {
|
||||
/// This function is wrapped by `shell::State`.
|
||||
pub fn run_now(&self, handle: &SubscriptionHandle, nvim: &mut NeovimRef) {
|
||||
let subscription = &self.0.get(&handle.event_name).unwrap()[handle.index];
|
||||
let args = subscription.args
|
||||
let args = subscription
|
||||
.args
|
||||
.iter()
|
||||
.map(|arg| nvim.eval(arg))
|
||||
.map(|res| {
|
||||
res.ok()
|
||||
.and_then(|val| {
|
||||
val.as_str().map(|s: &str| s.to_owned())
|
||||
})
|
||||
.and_then(|val| val.as_str().map(|s: &str| s.to_owned()))
|
||||
})
|
||||
.collect::<Option<Vec<String>>>();
|
||||
if let Some(args) = args {
|
||||
|
34
src/ui.rs
34
src/ui.rs
@ -61,7 +61,9 @@ impl Components {
|
||||
open_btn_box.pack_start(>k::Label::new("Open"), false, false, 3);
|
||||
open_btn_box.pack_start(
|
||||
>k::Image::new_from_icon_name("pan-down-symbolic", gtk::IconSize::Menu.into()),
|
||||
false, false, 3
|
||||
false,
|
||||
false,
|
||||
3,
|
||||
);
|
||||
open_btn.add(&open_btn_box);
|
||||
open_btn.set_can_focus(false);
|
||||
@ -184,8 +186,10 @@ impl Ui {
|
||||
window.show_all();
|
||||
|
||||
let comps_ref = self.comps.clone();
|
||||
let update_title = shell.state.borrow()
|
||||
.subscribe("BufEnter,DirChanged", &["expand('%:p')", "getcwd()"], move |args| {
|
||||
let update_title = shell.state.borrow().subscribe(
|
||||
"BufEnter,DirChanged",
|
||||
&["expand('%:p')", "getcwd()"],
|
||||
move |args| {
|
||||
let comps = comps_ref.borrow();
|
||||
let window = comps.window.as_ref().unwrap();
|
||||
let file_path = &args[0];
|
||||
@ -202,7 +206,8 @@ impl Ui {
|
||||
&file_path
|
||||
};
|
||||
window.set_title(filename);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
let comps_ref = self.comps.clone();
|
||||
let shell_ref = self.shell.clone();
|
||||
@ -245,19 +250,15 @@ impl Ui {
|
||||
.open_btn
|
||||
.connect_clicked(move |_| projects.borrow_mut().show());
|
||||
|
||||
let new_tab_btn = Button::new_from_icon_name(
|
||||
"tab-new-symbolic",
|
||||
gtk::IconSize::SmallToolbar.into(),
|
||||
);
|
||||
let new_tab_btn =
|
||||
Button::new_from_icon_name("tab-new-symbolic", gtk::IconSize::SmallToolbar.into());
|
||||
let shell_ref = Rc::clone(&self.shell);
|
||||
new_tab_btn.connect_clicked(move |_| shell_ref.borrow_mut().new_tab());
|
||||
new_tab_btn.set_can_focus(false);
|
||||
header_bar.pack_start(&new_tab_btn);
|
||||
|
||||
let paste_btn = Button::new_from_icon_name(
|
||||
"edit-paste",
|
||||
gtk::IconSize::SmallToolbar.into(),
|
||||
);
|
||||
let paste_btn =
|
||||
Button::new_from_icon_name("edit-paste", gtk::IconSize::SmallToolbar.into());
|
||||
let shell = self.shell.clone();
|
||||
paste_btn.connect_clicked(move |_| shell.borrow_mut().edit_paste());
|
||||
paste_btn.set_can_focus(false);
|
||||
@ -274,10 +275,13 @@ impl Ui {
|
||||
window.set_titlebar(Some(&header_bar));
|
||||
|
||||
let shell = self.shell.borrow();
|
||||
let update_subtitle = shell.state.borrow()
|
||||
.subscribe("DirChanged", &["getcwd()"], move |args| {
|
||||
let update_subtitle = shell.state.borrow().subscribe(
|
||||
"DirChanged",
|
||||
&["getcwd()"],
|
||||
move |args| {
|
||||
header_bar.set_subtitle(&*args[0]);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
update_subtitle
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user