Fix some indentation

This commit is contained in:
Manos Pitsidianakis 2018-07-24 14:38:46 +03:00
parent f1722691e2
commit 0dd379141d
No known key found for this signature in database
GPG Key ID: 73627C2F690DF710

View File

@ -360,8 +360,8 @@ impl<W: Write> State<W> {
return; return;
}, },
UIEventType::EditDraft(dir) => { UIEventType::EditDraft(dir) => {
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use std::io::Read; use std::io::Read;
let mut output = Command::new("msmtp") let mut output = Command::new("msmtp")
.arg("-t") .arg("-t")
.stdin(Stdio::piped()) .stdin(Stdio::piped())
@ -371,14 +371,14 @@ impl<W: Write> State<W> {
{ {
let mut in_pipe = output.stdin.as_mut().unwrap(); let mut in_pipe = output.stdin.as_mut().unwrap();
let mut buf = Vec::new(); let mut buf = Vec::new();
let mut f = std::fs::File::open(&dir).unwrap(); let mut f = std::fs::File::open(&dir).unwrap();
f.read_to_end(&mut buf).unwrap(); f.read_to_end(&mut buf).unwrap();
in_pipe.write(&buf).unwrap(); in_pipe.write(&buf).unwrap();
} }
let output = output.wait_with_output().expect("Failed to read stdout"); let output = output.wait_with_output().expect("Failed to read stdout");
return; return;
}, },
UIEventType::Input(Key::Char('t')) => UIEventType::Input(Key::Char('t')) =>
for i in 0..self.entities.len() { for i in 0..self.entities.len() {
@ -410,27 +410,27 @@ impl<W: Write> State<W> {
pub fn try_wait_on_child(&mut self) -> Option<bool> { pub fn try_wait_on_child(&mut self) -> Option<bool> {
if { if {
match self.child { match self.child {
Some(ForkType::NewDraft(_,ref mut c)) => { Some(ForkType::NewDraft(_,ref mut c)) => {
let mut w = c.try_wait(); let mut w = c.try_wait();
match w { match w {
Ok(Some(_)) => { true }, Ok(Some(_)) => { true },
Ok(None) => { false }, Ok(None) => { false },
Err(_) => { return None; }, Err(_) => { return None; },
}
},
Some(ForkType::Generic(ref mut c)) => {
let mut w = c.try_wait();
match w {
Ok(Some(_)) => { true },
Ok(None) => { false },
Err(_) => { return None; },
}
},
_ => {
return None;
} }
},
Some(ForkType::Generic(ref mut c)) => {
let mut w = c.try_wait();
match w {
Ok(Some(_)) => { true },
Ok(None) => { false },
Err(_) => { return None; },
}
},
_ => {
return None;
} }
} }
}
{ {
if let Some(ForkType::NewDraft(f, _)) = std::mem::replace(&mut self.child, None) { if let Some(ForkType::NewDraft(f, _)) = std::mem::replace(&mut self.child, None) {
self.rcv_event(UIEvent { id: 0, event_type: UIEventType::EditDraft(f) }); self.rcv_event(UIEvent { id: 0, event_type: UIEventType::EditDraft(f) });
@ -529,22 +529,22 @@ impl From<TermionKey> for Key {
* The main loop uses try_wait_on_child() to check if child has exited. * The main loop uses try_wait_on_child() to check if child has exited.
*/ */
pub fn get_events(stdin: std::io::Stdin, mut closure: impl FnMut(Key), mut exit: impl FnMut(), rx: chan::Receiver<bool>) -> (){ pub fn get_events(stdin: std::io::Stdin, mut closure: impl FnMut(Key), mut exit: impl FnMut(), rx: chan::Receiver<bool>) -> (){
for c in stdin.keys() { for c in stdin.keys() {
chan_select! { chan_select! {
default => {}, default => {},
rx.recv() -> val => { rx.recv() -> val => {
if let Some(true) = val { if let Some(true) = val {
exit(); exit();
return; return;
} else if let Some(false) = val { } else if let Some(false) = val {
return; return;
} }
}
};
if let Ok(k) = c {
closure(Key::from(k));
} }
};
if let Ok(k) = c {
closure(Key::from(k));
} }
}
} }