summaryrefslogtreecommitdiffstats
path: root/ui/src
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2018-07-22 15:44:44 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-06-10 19:40:24 +0300
commit7ed707a3099720254115b6da36e7dae2e63730f0 (patch)
tree61e4f30ab31aa791c3291ce7b5f1c5427a4e9338 /ui/src
parentbf0eb66b0294e5f70bfad96125006f55e4af0e59 (diff)
Print attachments of interest in the text body
Concerns #2
Diffstat (limited to 'ui/src')
-rw-r--r--ui/src/components/mail/listing.rs4
-rw-r--r--ui/src/components/utilities.rs16
2 files changed, 13 insertions, 7 deletions
diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs
index 9f63cb09..91813f4a 100644
--- a/ui/src/components/mail/listing.rs
+++ b/ui/src/components/mail/listing.rs
@@ -322,8 +322,8 @@ impl MailListing {
s.push_str(&format!("{:.85}", envelope.subject()));
}
let attach_count = envelope.body().count_attachments();
- if attach_count > 0 {
- s.push_str(&format!(" {}∞ ", attach_count));
+ if attach_count > 1 {
+ s.push_str(&format!(" {}∞ ", attach_count-1));
}
s
}
diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs
index cfa24c6f..12bea00d 100644
--- a/ui/src/components/utilities.rs
+++ b/ui/src/components/utilities.rs
@@ -3,6 +3,7 @@
use super::*;
use melib::mailbox::email::interpret_format_flowed;
+use melib::mailbox::email::Attachment;
/// A horizontally split in half container.
pub struct HSplit {
@@ -168,13 +169,17 @@ impl Pager {
text = String::from_utf8_lossy(&filter_child.wait_with_output().expect("Failed to wait on filter").stdout).to_string();
}
- let lines: Vec<&str> = text.trim().split('\n').collect();
- let height = lines.len();
+ let mut text = text.to_string();
+ if envelope.body().count_attachments() > 1 {
+ eprintln!("text was {}", text);
+ text = envelope.body().attachments().iter().fold(text, |mut s, a| { s.push_str(&format!("{}\n", a)); s });
+ eprintln!("text is {}", text);
+ }
+ let mut 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(' '));
- if false {
- interpret_format_flowed(&text);
- }
+ //interpret_format_flowed(&text);
Pager::print_string(&mut content, &text);
Pager {
cursor_pos: 0,
@@ -203,6 +208,7 @@ impl Pager {
let width = lines.iter().map(|l| l.len()).max().unwrap_or(0);
if width > 0 {
for (i, l) in lines.iter().enumerate() {
+ eprintln!("line: {:?}", l);
write_string_to_grid(l,
content,
Color::Default,