Add stub for format_flowed support

Concerns #17
embed
Manos Pitsidianakis 2018-07-22 14:05:12 +03:00
parent f267fe8c9e
commit f119789cb0
Signed by: Manos Pitsidianakis
GPG Key ID: 73627C2F690DF710
5 changed files with 30 additions and 6 deletions

View File

@ -99,10 +99,9 @@ impl AccountSettings {
}
}
#[derive(Debug)]
#[derive(Debug, Clone, Default)]
pub struct Settings {
pub accounts: HashMap<String, AccountSettings>,
pub pager: PagerSettings,
}

View File

@ -18,7 +18,7 @@ fn none() -> Option<String> {
}
/// Settings for the pager function.
#[derive(Debug, Deserialize)]
#[derive(Debug, Deserialize, Clone, Default)]
pub struct PagerSettings {
/// Number of context lines when going to next page.
/// Default: 0
@ -44,4 +44,9 @@ pub struct PagerSettings {
/// Default: None
#[serde(default = "none")]
pub filter: Option<String>,
/// Respect "format=flowed"
/// Default: true
#[serde(default = "true_val")]
pub format_flowed: bool,
}

View File

@ -334,3 +334,12 @@ impl Attachment {
counter
}
}
pub fn interpret_format_flowed(t: &str) -> String {
let mut n = String::with_capacity(t.len());
unimplemented!()
}

View File

@ -21,8 +21,10 @@
pub mod parser;
mod attachments;
use mailbox::backends::BackendOpGenerator;
use self::attachments::*;
pub use self::attachments::interpret_format_flowed;
use std::string::String;
use std::sync::Arc;

View File

@ -2,6 +2,8 @@
*/
use super::*;
use melib::mailbox::email::interpret_format_flowed;
/// A horizontally split in half container.
pub struct HSplit {
top: Entity,
@ -132,10 +134,14 @@ pub struct Pager {
content: CellBuffer,
}
// TODO: Make the `new` method content agnostic.
// TODO: Make a `new` method that is content agnostic.
impl Pager {
pub fn new(mail: &Envelope, pager_filter: Option<String>) -> Self {
let mut text = mail.body().text();
pub fn from_envelope(mailbox_idx: (usize, usize), envelope_idx: usize, context: &mut Context) -> Self {
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 mut text = envelope.body().text();
if let Some(bin) = pager_filter {
use std::io::Write;
use std::process::{Command, Stdio};
@ -158,6 +164,9 @@ impl Pager {
let height = lines.len();
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);
}
Pager::print_string(&mut content, &text);
Pager {
cursor_pos: 0,