Remove eprintlns and add some doc

embed
Manos Pitsidianakis 2018-07-22 23:11:07 +03:00
parent dcb1fe6c3a
commit bae613ec54
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
4 changed files with 6 additions and 21 deletions

View File

@ -96,10 +96,8 @@ fn main() {
/* Keep track of the input mode. See ui::UIMode for details */
'main: loop {
state.render();
eprintln!("entered main loop");
'inner: loop {
eprintln!("entered inner loop");
/* Check if any entities have sent reply events to State. */
let events: Vec<UIEvent> = state.context.replies();
for e in events {
@ -110,10 +108,8 @@ fn main() {
/* Poll on all channels. Currently we have the input channel for stdin, watching events and the signal watcher. */
chan_select! {
receiver.recv() -> r => {
eprintln!("received {:?}", r);
match r.unwrap() {
ThreadEvent::Input(k) => {
eprintln!(" match input");
match state.mode {
UIMode::Normal => {
match k {
@ -147,7 +143,6 @@ fn main() {
}
},
UIMode::Fork => {
eprintln!("UIMODE FORK");
break 'inner; // `goto` 'reap loop, and wait on child.
},
}
@ -156,14 +151,12 @@ fn main() {
state.rcv_event(UIEvent { id: 0, event_type: UIEventType::Notification(n.clone())});
state.redraw();
/* Don't handle this yet. */
eprintln!("Refresh mailbox {}", n);
},
ThreadEvent::UIEventType(UIEventType::ChangeMode(f)) => {
state.mode = f;
break 'inner; // `goto` 'reap loop, and wait on child.
}
ThreadEvent::UIEventType(e) => {
eprintln!(" match event");
state.rcv_event(UIEvent { id: 0, event_type: e});
state.render();
},
@ -172,7 +165,6 @@ fn main() {
signal.recv() -> signal => {
if state.mode != UIMode::Fork {
if let Some(Signal::WINCH) = signal {
eprintln!("resize, mode is {:?}", state.mode);
state.update_size();
state.render();
state.redraw();
@ -183,7 +175,6 @@ fn main() {
} // end of 'inner
'reap: loop {
eprintln!("reached reap loop");
match state.try_wait_on_child() {
Some(true) => {
make_input_thread(sender.clone(), rx.clone());

View File

@ -1,6 +1,8 @@
use super::*;
/// Contains an Envelope view, with sticky headers, a pager for the body, and subviews for more
/// menus
pub struct MailView {
coordinates: (usize, usize, usize),
pager: Option<Pager>,
@ -98,6 +100,7 @@ impl Component for MailView {
(envelope_idx, y + 1)
};
if self.dirty {
// TODO: pass string instead of envelope
self.pager = Some(Pager::from_envelope((self.coordinates.0, self.coordinates.1), envelope_idx, context));
self.dirty = false;
}

View File

@ -149,12 +149,11 @@ impl Pager {
let mailbox = &mut context.accounts[mailbox_idx.0][mailbox_idx.1].as_ref().unwrap().as_ref().unwrap();
let envelope : &Envelope = &mailbox.collection[envelope_idx];
let pager_filter: Option<&String> = context.settings.pager.filter.as_ref();
let format_flowed: bool = context.settings.pager.format_flowed;
//let format_flowed: bool = context.settings.pager.format_flowed;
let mut text = envelope.body().text();
if let Some(bin) = pager_filter {
use std::io::Write;
use std::process::{Command, Stdio};
eprintln!("{}", bin);
let mut filter_child = Command::new(bin)
.stdin(Stdio::piped())
.stdout(Stdio::piped())
@ -171,11 +170,9 @@ impl Pager {
}
let mut text = text.to_string();
if envelope.body().count_attachments() > 1 {
eprintln!("text was {}", text);
text = envelope.body().attachments().iter().enumerate().fold(text, |mut s, (idx, a)| { s.push_str(&format!("[{}] {}\n\n", idx, a)); s });
eprintln!("text is {}", text);
}
let mut lines: Vec<&str> = text.trim().split('\n').collect();
let lines: Vec<&str> = text.trim().split('\n').collect();
let height = lines.len() + 1;
let width = lines.iter().map(|l| l.len()).max().unwrap_or(0);
let mut content = CellBuffer::new(width, height, Cell::with_char(' '));
@ -234,7 +231,6 @@ impl Component for Pager {
if self.height == 0 || self.height == self.cursor_pos || self.width == 0 {
return;
}
eprintln!("drawing");
clear_area(grid,
(upper_left, bottom_right));
@ -246,7 +242,6 @@ impl Component for Pager {
context.dirty_areas.push_back(area);
}
fn process_event(&mut self, event: &UIEvent, _context: &mut Context) {
eprintln!("pager got {:?}", event);
match event.event_type {
UIEventType::Input(Key::Char('k')) => {
if self.cursor_pos > 0 {

View File

@ -318,7 +318,6 @@ impl<W: Write> State<W> {
/// Convert user commands to actions/method calls.
fn parse_command(&mut self, cmd: String) {
//TODO: Make ex mode useful
eprintln!("received command: {}", cmd);
let result = goto(&cmd.as_bytes()).to_full_result();
@ -358,7 +357,6 @@ impl<W: Write> State<W> {
in_pipe.write(&buf).unwrap();
}
let output = output.wait_with_output().expect("Failed to read stdout");
eprintln!("{}",String::from_utf8_lossy(&output.stdout));
return;
},
@ -392,7 +390,7 @@ impl<W: Write> State<W> {
pub fn try_wait_on_child(&mut self) -> Option<bool> {
if {
match self.child {
Some(ForkType::NewDraft(_,ref mut c)) => {
Some(ForkType::NewDraft(_,ref mut c)) => {
let mut w = c.try_wait();
match w {
Ok(Some(_)) => { true },
@ -408,7 +406,6 @@ impl<W: Write> State<W> {
Err(_) => { return None; },
}
},
_ => {
return None;
}
@ -517,7 +514,6 @@ pub fn get_events(stdin: std::io::Stdin, mut closure: impl FnMut(Key), mut exit:
};
if let Ok(k) = c {
eprintln!("rcvd {:?}", k);
closure(Key::from(k));
}
}