Fix warnings, lints, and 2018 errors
parent
a51a164711
commit
24831b3c13
|
@ -3,6 +3,7 @@ name = "debug_printer"
|
||||||
version = "0.0.1" #:version
|
version = "0.0.1" #:version
|
||||||
authors = ["Manos Pitsidianakis <el13635@mail.ntua.gr>"]
|
authors = ["Manos Pitsidianakis <el13635@mail.ntua.gr>"]
|
||||||
workspace = ".."
|
workspace = ".."
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "debugprinter"
|
name = "debugprinter"
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
[package]
|
[package]
|
||||||
name = "melib"
|
name = "melib"
|
||||||
version = "0.0.1" #:version
|
version = "0.0.1" #:version
|
||||||
edition = "2018"
|
|
||||||
authors = ["Manos Pitsidianakis <el13635@mail.ntua.gr>"]
|
authors = ["Manos Pitsidianakis <el13635@mail.ntua.gr>"]
|
||||||
workspace = ".."
|
workspace = ".."
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
|
|
|
@ -173,7 +173,7 @@ impl Card {
|
||||||
self.extra_properties.insert(key.to_string(), value);
|
self.extra_properties.insert(key.to_string(), value);
|
||||||
}
|
}
|
||||||
pub fn extra_property(&self, key: &str) -> Option<&str> {
|
pub fn extra_property(&self, key: &str) -> Option<&str> {
|
||||||
self.extra_properties.get(key).map(|v| v.as_str())
|
self.extra_properties.get(key).map(String::as_str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,9 +168,7 @@ impl<'a> BackendOp for MaildirOp {
|
||||||
let hash_index = self.hash_index.clone();
|
let hash_index = self.hash_index.clone();
|
||||||
let mut map = hash_index.lock().unwrap();
|
let mut map = hash_index.lock().unwrap();
|
||||||
let map = map.entry(self.folder_hash).or_default();
|
let map = map.entry(self.folder_hash).or_default();
|
||||||
if let maildir_path = map.entry(old_hash).or_default() {
|
map.entry(old_hash).or_default().modified = Some(new_name.clone());
|
||||||
maildir_path.modified = Some(new_name.clone().into());
|
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,11 +245,11 @@ impl BackendFolder for MaildirFolder {
|
||||||
name: self.name.clone(),
|
name: self.name.clone(),
|
||||||
path: self.path.clone(),
|
path: self.path.clone(),
|
||||||
children: self.children.clone(),
|
children: self.children.clone(),
|
||||||
parent: self.parent.clone(),
|
parent: self.parent,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent(&self) -> Option<FolderHash> {
|
fn parent(&self) -> Option<FolderHash> {
|
||||||
self.parent.clone()
|
self.parent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,8 @@ use crate::conf::AccountSettings;
|
||||||
use crate::email::{Envelope, EnvelopeHash};
|
use crate::email::{Envelope, EnvelopeHash};
|
||||||
use crate::error::{MeliError, Result};
|
use crate::error::{MeliError, Result};
|
||||||
|
|
||||||
use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
|
extern crate notify;
|
||||||
|
use self::notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use std::sync::mpsc::channel;
|
use std::sync::mpsc::channel;
|
||||||
|
@ -166,7 +167,7 @@ fn move_to_cur(p: PathBuf) -> PathBuf {
|
||||||
new.set_extension(":2,");
|
new.set_extension(":2,");
|
||||||
}
|
}
|
||||||
debug!("moved to cur: {}", new.display());
|
debug!("moved to cur: {}", new.display());
|
||||||
fs::rename(p, &new).unwrap();
|
fs::rename(&p, &new).unwrap();
|
||||||
new
|
new
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,11 +264,6 @@ impl MailBackend for MaildirType {
|
||||||
} else {
|
} else {
|
||||||
/* Did we just miss a Create event? In any case, create
|
/* Did we just miss a Create event? In any case, create
|
||||||
* envelope. */
|
* envelope. */
|
||||||
|
|
||||||
/* Drop the lock manually as add_path_to_index would deadlock
|
|
||||||
* */
|
|
||||||
drop(index_lock);
|
|
||||||
drop(hash_indexes_lock);
|
|
||||||
if let Some(env) = add_path_to_index(
|
if let Some(env) = add_path_to_index(
|
||||||
&hash_indexes,
|
&hash_indexes,
|
||||||
folder_hash,
|
folder_hash,
|
||||||
|
@ -369,10 +365,6 @@ impl MailBackend for MaildirType {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_path_buf();
|
.to_path_buf();
|
||||||
debug!("filename = {:?}", file_name);
|
debug!("filename = {:?}", file_name);
|
||||||
/* Drop the lock manually as add_path_to_index would deadlock
|
|
||||||
* */
|
|
||||||
drop(index_lock);
|
|
||||||
drop(hash_indexes_lock);
|
|
||||||
if let Some(env) = add_path_to_index(
|
if let Some(env) = add_path_to_index(
|
||||||
&hash_indexes,
|
&hash_indexes,
|
||||||
folder_hash,
|
folder_hash,
|
||||||
|
|
|
@ -130,56 +130,50 @@ impl Collection {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let mut threads = Threads::new(&mut envelopes);
|
let mut new_threads = Threads::new(&mut envelopes);
|
||||||
|
|
||||||
for (h, e) in envelopes {
|
for (h, e) in envelopes {
|
||||||
self.envelopes.insert(h, e);
|
self.envelopes.insert(h, e);
|
||||||
}
|
}
|
||||||
for (t_fh, t) in self.threads.iter_mut() {
|
let &mut Collection {
|
||||||
if self.sent_folder.map(|f| f == folder_hash).unwrap_or(false) {
|
ref mut threads,
|
||||||
let mut ordered_hash_set = threads
|
ref mut envelopes,
|
||||||
|
ref sent_folder,
|
||||||
|
..
|
||||||
|
} = self;
|
||||||
|
for (t_fh, t) in threads.iter_mut() {
|
||||||
|
if sent_folder.map(|f| f == folder_hash).unwrap_or(false) {
|
||||||
|
let mut ordered_hash_set = new_threads
|
||||||
.hash_set
|
.hash_set
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect::<Vec<EnvelopeHash>>();
|
.collect::<Vec<EnvelopeHash>>();
|
||||||
unsafe {
|
ordered_hash_set.sort_by(|a, b| {
|
||||||
/* FIXME NLL
|
envelopes[a]
|
||||||
* Sorting ordered_hash_set triggers a borrow which should not happen with NLL
|
.date()
|
||||||
* probably */
|
.partial_cmp(&envelopes[b].date())
|
||||||
let envelopes = &self.envelopes as *const FnvHashMap<EnvelopeHash, Envelope>;
|
.unwrap()
|
||||||
ordered_hash_set.sort_by(|a, b| {
|
});
|
||||||
(*envelopes)[a]
|
|
||||||
.date()
|
|
||||||
.partial_cmp(&(*(envelopes))[b].date())
|
|
||||||
.unwrap()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
for h in ordered_hash_set {
|
for h in ordered_hash_set {
|
||||||
t.insert_reply(&mut self.envelopes, h);
|
t.insert_reply(envelopes, h);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if self.sent_folder.map(|f| f == *t_fh).unwrap_or(false) {
|
if sent_folder.map(|f| f == *t_fh).unwrap_or(false) {
|
||||||
let mut ordered_hash_set =
|
let mut ordered_hash_set =
|
||||||
t.hash_set.iter().cloned().collect::<Vec<EnvelopeHash>>();
|
t.hash_set.iter().cloned().collect::<Vec<EnvelopeHash>>();
|
||||||
unsafe {
|
ordered_hash_set.sort_by(|a, b| {
|
||||||
/* FIXME NLL
|
envelopes[a]
|
||||||
* Sorting ordered_hash_set triggers a borrow which should not happen with NLL
|
.date()
|
||||||
* probably */
|
.partial_cmp(&envelopes[b].date())
|
||||||
let envelopes = &self.envelopes as *const FnvHashMap<EnvelopeHash, Envelope>;
|
.unwrap()
|
||||||
ordered_hash_set.sort_by(|a, b| {
|
});
|
||||||
(*envelopes)[a]
|
|
||||||
.date()
|
|
||||||
.partial_cmp(&(*(envelopes))[b].date())
|
|
||||||
.unwrap()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
for h in ordered_hash_set {
|
for h in ordered_hash_set {
|
||||||
threads.insert_reply(&mut self.envelopes, h);
|
new_threads.insert_reply(envelopes, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.threads.insert(folder_hash, threads);
|
threads.insert(folder_hash, new_threads);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, old_hash: EnvelopeHash, envelope: Envelope, folder_hash: FolderHash) {
|
pub fn update(&mut self, old_hash: EnvelopeHash, envelope: Envelope, folder_hash: FolderHash) {
|
||||||
|
@ -190,7 +184,8 @@ impl Collection {
|
||||||
self.envelopes.insert(new_hash, envelope);
|
self.envelopes.insert(new_hash, envelope);
|
||||||
if self.sent_folder.map(|f| f == folder_hash).unwrap_or(false) {
|
if self.sent_folder.map(|f| f == folder_hash).unwrap_or(false) {
|
||||||
for (_, t) in self.threads.iter_mut() {
|
for (_, t) in self.threads.iter_mut() {
|
||||||
t.update_envelope(old_hash, new_hash, &self.envelopes);
|
t.update_envelope(old_hash, new_hash, &self.envelopes)
|
||||||
|
.unwrap_or(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,7 +30,7 @@ mod attachment_types;
|
||||||
pub mod attachments;
|
pub mod attachments;
|
||||||
pub use crate::attachments::*;
|
pub use crate::attachments::*;
|
||||||
pub mod parser;
|
pub mod parser;
|
||||||
use parser::BytesExt;
|
use crate::parser::BytesExt;
|
||||||
|
|
||||||
use crate::backends::BackendOp;
|
use crate::backends::BackendOp;
|
||||||
use crate::error::{MeliError, Result};
|
use crate::error::{MeliError, Result};
|
||||||
|
@ -472,8 +472,7 @@ impl Envelope {
|
||||||
let b = builder.build();
|
let b = builder.build();
|
||||||
let subs = b.attachments();
|
let subs = b.attachments();
|
||||||
|
|
||||||
self.has_attachments =
|
self.has_attachments = subs.iter().any(|sub| !sub.is_text());
|
||||||
subs.iter().fold(false, |acc, sub| acc || !sub.is_text());
|
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ impl fmt::Debug for Attachment {
|
||||||
{
|
{
|
||||||
let mut text = Vec::with_capacity(4096);
|
let mut text = Vec::with_capacity(4096);
|
||||||
self.get_text_recursive(&mut text);
|
self.get_text_recursive(&mut text);
|
||||||
std::str::from_utf8(&text).map(|r| r.to_string()).unwrap_or_else(|e| format!("Unicode error {}", e))
|
std::str::from_utf8(&text).map(std::string::ToString::to_string).unwrap_or_else(|e| format!("Unicode error {}", e))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -346,7 +346,7 @@ impl Attachment {
|
||||||
String::from_utf8_lossy(text.as_slice().trim()).into()
|
String::from_utf8_lossy(text.as_slice().trim()).into()
|
||||||
}
|
}
|
||||||
pub fn description(&self) -> Vec<String> {
|
pub fn description(&self) -> Vec<String> {
|
||||||
self.attachments().iter().map(|a| a.text()).collect()
|
self.attachments().iter().map(Attachment::text).collect()
|
||||||
}
|
}
|
||||||
pub fn mime_type(&self) -> String {
|
pub fn mime_type(&self) -> String {
|
||||||
format!("{}", self.content_type).to_string()
|
format!("{}", self.content_type).to_string()
|
||||||
|
@ -408,7 +408,7 @@ impl Attachment {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
true
|
||||||
}
|
}
|
||||||
ContentType::Multipart {
|
ContentType::Multipart {
|
||||||
kind: MultipartType::Signed,
|
kind: MultipartType::Signed,
|
||||||
|
@ -417,7 +417,7 @@ impl Attachment {
|
||||||
} => subattachments
|
} => subattachments
|
||||||
.iter()
|
.iter()
|
||||||
.find(|s| s.content_type != ContentType::PGPSignature)
|
.find(|s| s.content_type != ContentType::PGPSignature)
|
||||||
.map(|s| s.is_html())
|
.map(Attachment::is_html)
|
||||||
.unwrap_or(false),
|
.unwrap_or(false),
|
||||||
ContentType::Multipart {
|
ContentType::Multipart {
|
||||||
ref subattachments, ..
|
ref subattachments, ..
|
||||||
|
@ -468,11 +468,14 @@ fn decode_rfc822(_raw: &[u8]) -> Attachment {
|
||||||
type Filter<'a> = Box<FnMut(&'a Attachment, &mut Vec<u8>) -> () + 'a>;
|
type Filter<'a> = Box<FnMut(&'a Attachment, &mut Vec<u8>) -> () + 'a>;
|
||||||
|
|
||||||
fn decode_rec_helper<'a>(a: &'a Attachment, filter: &mut Option<Filter<'a>>) -> Vec<u8> {
|
fn decode_rec_helper<'a>(a: &'a Attachment, filter: &mut Option<Filter<'a>>) -> Vec<u8> {
|
||||||
let ret = match a.content_type {
|
match a.content_type {
|
||||||
ContentType::Unsupported { .. } => Vec::new(),
|
ContentType::Unsupported { .. } => Vec::new(),
|
||||||
ContentType::Text { .. } => decode_helper(a, filter),
|
ContentType::Text { .. } => decode_helper(a, filter),
|
||||||
ContentType::PGPSignature => a.content_type.to_string().into_bytes(),
|
ContentType::PGPSignature => a.content_type.to_string().into_bytes(),
|
||||||
ContentType::MessageRfc822 => decode_rec(&decode_rfc822(&a.raw), None),
|
ContentType::MessageRfc822 => {
|
||||||
|
let temp = decode_rfc822(&a.raw);
|
||||||
|
decode_rec(&temp, None)
|
||||||
|
}
|
||||||
ContentType::Multipart {
|
ContentType::Multipart {
|
||||||
ref kind,
|
ref kind,
|
||||||
ref subattachments,
|
ref subattachments,
|
||||||
|
@ -497,8 +500,7 @@ fn decode_rec_helper<'a>(a: &'a Attachment, filter: &mut Option<Filter<'a>>) ->
|
||||||
vec
|
vec
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
ret
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decode_rec<'a>(a: &'a Attachment, mut filter: Option<Filter<'a>>) -> Vec<u8> {
|
pub fn decode_rec<'a>(a: &'a Attachment, mut filter: Option<Filter<'a>>) -> Vec<u8> {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use super::*;
|
||||||
|
|
||||||
pub fn encode_header(value: &str) -> String {
|
pub fn encode_header(value: &str) -> String {
|
||||||
eprintln!("encoding \"{}\"", value);
|
eprintln!("encoding \"{}\"", value);
|
||||||
let mut ret = String::with_capacity(5 / 3 * value.len());
|
let mut ret = String::with_capacity(value.len());
|
||||||
for word in value.split_whitespace() {
|
for word in value.split_whitespace() {
|
||||||
if word.is_ascii() {
|
if word.is_ascii() {
|
||||||
ret.push_str(word);
|
ret.push_str(word);
|
||||||
|
|
|
@ -896,11 +896,11 @@ mod tests {
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn test_attachments() {
|
fn test_attachments() {
|
||||||
use std::io::Read;
|
|
||||||
let mut buffer: Vec<u8> = Vec::new();
|
|
||||||
//FIXME: add file
|
//FIXME: add file
|
||||||
return;
|
return;
|
||||||
/*
|
/*
|
||||||
|
use std::io::Read;
|
||||||
|
let mut buffer: Vec<u8> = Vec::new();
|
||||||
let _ = std::fs::File::open("").unwrap().read_to_end(&mut buffer);
|
let _ = std::fs::File::open("").unwrap().read_to_end(&mut buffer);
|
||||||
let boundary = b"b1_4382d284f0c601a737bb32aaeda53160";
|
let boundary = b"b1_4382d284f0c601a737bb32aaeda53160";
|
||||||
let (_, body) = match mail(&buffer).to_full_result() {
|
let (_, body) = match mail(&buffer).to_full_result() {
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
extern crate unicode_segmentation;
|
||||||
|
use self::unicode_segmentation::UnicodeSegmentation;
|
||||||
|
|
||||||
pub trait Graphemes: UnicodeSegmentation + CodePointsIter {
|
pub trait Graphemes: UnicodeSegmentation + CodePointsIter {
|
||||||
fn split_graphemes<'a>(&'a self) -> Vec<&'a str> {
|
fn split_graphemes<'a>(&'a self) -> Vec<&'a str> {
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub mod dbg {
|
||||||
"[{:?}] {}:{}_{}: ",
|
"[{:?}] {}:{}_{}: ",
|
||||||
std::thread::current()
|
std::thread::current()
|
||||||
.name()
|
.name()
|
||||||
.map(|v| v.to_string())
|
.map(std::string::ToString::to_string)
|
||||||
.unwrap_or_else(|| format!("{:?}", std::thread::current().id())),
|
.unwrap_or_else(|| format!("{:?}", std::thread::current().id())),
|
||||||
file!(),
|
file!(),
|
||||||
line!(),
|
line!(),
|
||||||
|
@ -48,7 +48,7 @@ pub mod dbg {
|
||||||
"[{:?}] {}:{}_{}: ",
|
"[{:?}] {}:{}_{}: ",
|
||||||
std::thread::current()
|
std::thread::current()
|
||||||
.name()
|
.name()
|
||||||
.map(|v| v.to_string())
|
.map(std::string::ToString::to_string)
|
||||||
.unwrap_or_else(|| format!("{:?}", std::thread::current().id())),
|
.unwrap_or_else(|| format!("{:?}", std::thread::current().id())),
|
||||||
file!(),
|
file!(),
|
||||||
line!(),
|
line!(),
|
||||||
|
@ -65,7 +65,7 @@ pub mod dbg {
|
||||||
"[{:?}] {}:{}_{}: ",
|
"[{:?}] {}:{}_{}: ",
|
||||||
std::thread::current()
|
std::thread::current()
|
||||||
.name()
|
.name()
|
||||||
.map(|v| v.to_string())
|
.map(std::string::ToString::to_string)
|
||||||
.unwrap_or_else(|| format!("{:?}", std::thread::current().id())),
|
.unwrap_or_else(|| format!("{:?}", std::thread::current().id())),
|
||||||
file!(),
|
file!(),
|
||||||
line!(),
|
line!(),
|
||||||
|
@ -88,7 +88,7 @@ pub mod grapheme_clusters;
|
||||||
pub mod mailbox;
|
pub mod mailbox;
|
||||||
pub mod thread;
|
pub mod thread;
|
||||||
pub use crate::email::*;
|
pub use crate::email::*;
|
||||||
pub use thread::*;
|
pub use crate::thread::*;
|
||||||
mod wcwidth;
|
mod wcwidth;
|
||||||
pub use self::grapheme_clusters::*;
|
pub use self::grapheme_clusters::*;
|
||||||
pub use self::wcwidth::*;
|
pub use self::wcwidth::*;
|
||||||
|
@ -112,11 +112,11 @@ extern crate bitflags;
|
||||||
extern crate fnv;
|
extern crate fnv;
|
||||||
extern crate uuid;
|
extern crate uuid;
|
||||||
|
|
||||||
pub use conf::*;
|
pub use crate::conf::*;
|
||||||
pub use mailbox::*;
|
pub use crate::mailbox::*;
|
||||||
|
|
||||||
pub use backends::{Backends, RefreshEvent, RefreshEventConsumer};
|
pub use crate::backends::{Backends, RefreshEvent, RefreshEventConsumer};
|
||||||
pub use email::{Envelope, Flag};
|
pub use crate::email::{Envelope, Flag};
|
||||||
pub use error::{MeliError, Result};
|
pub use crate::error::{MeliError, Result};
|
||||||
|
|
||||||
pub use addressbook::*;
|
pub use crate::addressbook::*;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::iter::Extend;
|
use std::iter::Extend;
|
||||||
use std::ops::Index;
|
use std::ops::Index;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Default)]
|
||||||
pub struct StackVec<T: Default + Copy + std::fmt::Debug> {
|
pub struct StackVec<T: Default + Copy + std::fmt::Debug> {
|
||||||
len: usize,
|
len: usize,
|
||||||
array: [T; 32],
|
array: [T; 32],
|
||||||
|
@ -42,7 +42,7 @@ impl<T: Default + Copy + std::fmt::Debug> StackVec<T> {
|
||||||
self.heap_vec.pop()
|
self.heap_vec.pop()
|
||||||
} else {
|
} else {
|
||||||
let ret = self.array[self.len - 1];
|
let ret = self.array[self.len - 1];
|
||||||
self.len = self.len - 1;
|
self.len -= 1;
|
||||||
Some(ret)
|
Some(ret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,7 @@ use std::mem;
|
||||||
use std::ops::Index;
|
use std::ops::Index;
|
||||||
use std::result::Result as StdResult;
|
use std::result::Result as StdResult;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
use std::string::ToString;
|
||||||
|
|
||||||
type Envelopes = FnvHashMap<EnvelopeHash, Envelope>;
|
type Envelopes = FnvHashMap<EnvelopeHash, Envelope>;
|
||||||
|
|
||||||
|
@ -82,9 +83,12 @@ fn rec_change_root_parent(
|
||||||
idx: ThreadHash,
|
idx: ThreadHash,
|
||||||
new_root: ThreadHash,
|
new_root: ThreadHash,
|
||||||
) {
|
) {
|
||||||
let entry = b.entry(idx).or_default();
|
let parent = {
|
||||||
entry.thread_group = new_root;
|
let entry = b.entry(idx).or_default();
|
||||||
if let Some(p) = entry.parent {
|
entry.thread_group = new_root;
|
||||||
|
entry.parent
|
||||||
|
};
|
||||||
|
if let Some(p) = parent {
|
||||||
rec_change_children(b, p, new_root);
|
rec_change_children(b, p, new_root);
|
||||||
rec_change_root_parent(b, p, new_root);
|
rec_change_root_parent(b, p, new_root);
|
||||||
}
|
}
|
||||||
|
@ -109,8 +113,8 @@ fn rec_change_children(
|
||||||
macro_rules! remove_from_parent {
|
macro_rules! remove_from_parent {
|
||||||
($buf:expr, $idx:expr) => {{
|
($buf:expr, $idx:expr) => {{
|
||||||
let mut parent: Option<ThreadHash> = None;
|
let mut parent: Option<ThreadHash> = None;
|
||||||
let entry = $buf.entry($idx).or_default();
|
let entry_parent = $buf.entry($idx).or_default().parent;
|
||||||
if let Some(p) = entry.parent {
|
if let Some(p) = entry_parent {
|
||||||
parent = Some(p);
|
parent = Some(p);
|
||||||
if let Some(pos) = $buf[&p].children.iter().position(|c| *c == $idx) {
|
if let Some(pos) = $buf[&p].children.iter().position(|c| *c == $idx) {
|
||||||
$buf.entry(p).and_modify(|e| {
|
$buf.entry(p).and_modify(|e| {
|
||||||
|
@ -964,14 +968,14 @@ impl Threads {
|
||||||
.get(
|
.get(
|
||||||
envelopes[&env_hash]
|
envelopes[&env_hash]
|
||||||
.in_reply_to()
|
.in_reply_to()
|
||||||
.map(|mgid| mgid.raw())
|
.map(crate::email::StrBuild::raw)
|
||||||
.unwrap_or(&[]),
|
.unwrap_or(&[]),
|
||||||
)
|
)
|
||||||
.map(|h| *h);
|
.cloned();
|
||||||
if let Some(id) = self
|
if let Some(id) = self
|
||||||
.message_ids
|
.message_ids
|
||||||
.get(envelopes[&env_hash].message_id().raw())
|
.get(envelopes[&env_hash].message_id().raw())
|
||||||
.map(|h| *h)
|
.cloned()
|
||||||
{
|
{
|
||||||
self.thread_nodes.entry(id).and_modify(|n| {
|
self.thread_nodes.entry(id).and_modify(|n| {
|
||||||
n.message = Some(env_hash);
|
n.message = Some(env_hash);
|
||||||
|
@ -1069,11 +1073,8 @@ impl Threads {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let no_parent: bool = if let Some(node) = self.thread_nodes.get(&node_idx) {
|
let no_parent: bool = if let Some(node) = self.thread_nodes.get(&node_idx) {
|
||||||
match (node.parent, node.message, node.children.len()) {
|
if let (None, None, 0) = (node.parent, node.message, node.children.len()) {
|
||||||
(None, None, 0) => {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
node.parent.is_none()
|
node.parent.is_none()
|
||||||
} else {
|
} else {
|
||||||
|
@ -1085,10 +1086,10 @@ impl Threads {
|
||||||
|
|
||||||
if no_parent {
|
if no_parent {
|
||||||
let tree = self.tree.get_mut();
|
let tree = self.tree.get_mut();
|
||||||
if let Some(tree) = tree.iter_mut().find(|t| t.id == id) {
|
if let Some(pos) = tree.iter().position(|t| t.id == id) {
|
||||||
*tree = ThreadTree::new(id);
|
tree[pos] = ThreadTree::new(id);
|
||||||
node_build(
|
node_build(
|
||||||
tree,
|
&mut tree[pos],
|
||||||
id,
|
id,
|
||||||
*(self.sort.borrow()),
|
*(self.sort.borrow()),
|
||||||
&mut self.thread_nodes,
|
&mut self.thread_nodes,
|
||||||
|
@ -1481,7 +1482,7 @@ impl Threads {
|
||||||
ref_ptr = parent_id;
|
ref_ptr = parent_id;
|
||||||
continue;
|
continue;
|
||||||
} */
|
} */
|
||||||
if !self.thread_nodes[&ref_ptr].parent.is_none() {
|
if self.thread_nodes[&ref_ptr].parent.is_some() {
|
||||||
if self.thread_nodes[&parent_id].parent == Some(ref_ptr) {
|
if self.thread_nodes[&parent_id].parent == Some(ref_ptr) {
|
||||||
eprintln!("ALARM");
|
eprintln!("ALARM");
|
||||||
remove_from_parent!(&mut self.thread_nodes, parent_id);
|
remove_from_parent!(&mut self.thread_nodes, parent_id);
|
||||||
|
@ -1506,12 +1507,9 @@ impl Threads {
|
||||||
while i < tree.len() {
|
while i < tree.len() {
|
||||||
// Evaluate if useless
|
// Evaluate if useless
|
||||||
let node = &self.thread_nodes[&tree[i].id];
|
let node = &self.thread_nodes[&tree[i].id];
|
||||||
match (node.parent, node.message, node.children.len()) {
|
if let (None, None, 0) = (node.parent, node.message, node.children.len()) {
|
||||||
(None, None, 0) => {
|
tree.remove(i);
|
||||||
tree.remove(i);
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
@ -1570,14 +1568,9 @@ fn node_build(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Some(node) = thread_nodes.get(&idx) {
|
||||||
if let Some(node) = thread_nodes.get(&idx) {
|
if let (None, None, 0) = (node.parent, node.message, node.children.len()) {
|
||||||
match (node.parent, node.message, node.children.len()) {
|
return;
|
||||||
(None, None, 0) => {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1648,9 +1641,9 @@ fn print_threadnodes(
|
||||||
"\t".repeat(level),
|
"\t".repeat(level),
|
||||||
node_hash,
|
node_hash,
|
||||||
"\t".repeat(level),
|
"\t".repeat(level),
|
||||||
nodes[&node_hash].message().as_ref().map(|m| format!("{} - {}\n{}\t\t{}", envelopes[m].message_id_display(), envelopes[m].subject(), "\t".repeat(level), envelopes[m].references().iter().map(|r| r.to_string()).collect::<Vec<String>>().join(", "))).unwrap_or_else(|| "None".to_string()),
|
nodes[&node_hash].message().as_ref().map(|m| format!("{} - {}\n{}\t\t{}", envelopes[m].message_id_display(), envelopes[m].subject(), "\t".repeat(level), envelopes[m].references().iter().map(ToString::to_string).collect::<Vec<String>>().join(", "))).unwrap_or_else(|| "None".to_string()),
|
||||||
"\t".repeat(level),
|
"\t".repeat(level),
|
||||||
nodes[&node_hash].parent().as_ref().map(|p| p.to_string()).unwrap_or_else(|| "None".to_string()),
|
nodes[&node_hash].parent().as_ref().map(ToString::to_string).unwrap_or_else(|| "None".to_string()),
|
||||||
"\t".repeat(level),
|
"\t".repeat(level),
|
||||||
nodes[&node_hash].thread_group,
|
nodes[&node_hash].thread_group,
|
||||||
"\t".repeat(level),
|
"\t".repeat(level),
|
||||||
|
|
|
@ -3,6 +3,7 @@ name = "testing"
|
||||||
version = "0.0.1" #:version
|
version = "0.0.1" #:version
|
||||||
authors = ["Manos Pitsidianakis <el13635@mail.ntua.gr>"]
|
authors = ["Manos Pitsidianakis <el13635@mail.ntua.gr>"]
|
||||||
workspace = ".."
|
workspace = ".."
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "emailparse"
|
name = "emailparse"
|
||||||
|
|
|
@ -3,6 +3,7 @@ name = "ui"
|
||||||
version = "0.0.1" #:version
|
version = "0.0.1" #:version
|
||||||
authors = ["Manos Pitsidianakis <el13635@mail.ntua.gr>"]
|
authors = ["Manos Pitsidianakis <el13635@mail.ntua.gr>"]
|
||||||
workspace = ".."
|
workspace = ".."
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
xdg = "2.1.0" # >:c
|
xdg = "2.1.0" # >:c
|
||||||
|
|
|
@ -28,7 +28,7 @@ See the `Component` Trait for more details.
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
pub mod mail;
|
pub mod mail;
|
||||||
pub use mail::*;
|
pub use crate::mail::*;
|
||||||
|
|
||||||
pub mod notifications;
|
pub mod notifications;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ pub mod utilities;
|
||||||
pub use self::utilities::*;
|
pub use self::utilities::*;
|
||||||
|
|
||||||
pub mod contacts;
|
pub mod contacts;
|
||||||
pub use contacts::*;
|
pub use crate::contacts::*;
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fmt::{Debug, Display};
|
use std::fmt::{Debug, Display};
|
||||||
|
|
|
@ -139,7 +139,7 @@ impl Component for ContactManager {
|
||||||
match self.form.buttons_result() {
|
match self.form.buttons_result() {
|
||||||
None => {}
|
None => {}
|
||||||
Some(true) => {
|
Some(true) => {
|
||||||
let mut fields = std::mem::replace(&mut self.form, FormWidget::default())
|
let fields = std::mem::replace(&mut self.form, FormWidget::default())
|
||||||
.collect()
|
.collect()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let fields: FnvHashMap<String, String> = fields
|
let fields: FnvHashMap<String, String> = fields
|
||||||
|
|
|
@ -27,9 +27,9 @@ use melib::backends::FolderHash;
|
||||||
use melib::thread::ThreadHash;
|
use melib::thread::ThreadHash;
|
||||||
|
|
||||||
pub mod listing;
|
pub mod listing;
|
||||||
pub use listing::*;
|
pub use crate::listing::*;
|
||||||
pub mod view;
|
pub mod view;
|
||||||
pub use view::*;
|
pub use crate::view::*;
|
||||||
mod compose;
|
mod compose;
|
||||||
pub use self::compose::*;
|
pub use self::compose::*;
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ impl Composer {
|
||||||
*/
|
*/
|
||||||
pub fn edit(account_pos: usize, h: EnvelopeHash, context: &Context) -> Self {
|
pub fn edit(account_pos: usize, h: EnvelopeHash, context: &Context) -> Self {
|
||||||
let mut ret = Composer::default();
|
let mut ret = Composer::default();
|
||||||
let op = context.accounts[account_pos].operation(&h);
|
let op = context.accounts[account_pos].operation(h);
|
||||||
let envelope: &Envelope = context.accounts[account_pos].get_env(&h);
|
let envelope: &Envelope = context.accounts[account_pos].get_env(&h);
|
||||||
|
|
||||||
ret.draft = Draft::edit(envelope, op);
|
ret.draft = Draft::edit(envelope, op);
|
||||||
|
@ -149,7 +149,7 @@ impl Composer {
|
||||||
let mut ret = Composer::default();
|
let mut ret = Composer::default();
|
||||||
let p = &thread_nodes[&msg];
|
let p = &thread_nodes[&msg];
|
||||||
let parent_message = &account.collection[&p.message().unwrap()];
|
let parent_message = &account.collection[&p.message().unwrap()];
|
||||||
let mut op = account.operation(&parent_message.hash());
|
let mut op = account.operation(parent_message.hash());
|
||||||
let parent_bytes = op.as_bytes();
|
let parent_bytes = op.as_bytes();
|
||||||
|
|
||||||
ret.draft = Draft::new_reply(parent_message, parent_bytes.unwrap());
|
ret.draft = Draft::new_reply(parent_message, parent_bytes.unwrap());
|
||||||
|
@ -538,7 +538,7 @@ impl Component for Composer {
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("Failed to start mailer command");
|
.expect("Failed to start mailer command");
|
||||||
{
|
{
|
||||||
let mut stdin = msmtp.stdin.as_mut().expect("failed to open stdin");
|
let stdin = msmtp.stdin.as_mut().expect("failed to open stdin");
|
||||||
self.update_draft();
|
self.update_draft();
|
||||||
let draft = self.draft.clone().finalise().unwrap();
|
let draft = self.draft.clone().finalise().unwrap();
|
||||||
stdin
|
stdin
|
||||||
|
@ -582,8 +582,7 @@ impl Component for Composer {
|
||||||
}
|
}
|
||||||
/* update Draft's headers based on form values */
|
/* update Draft's headers based on form values */
|
||||||
self.update_draft();
|
self.update_draft();
|
||||||
let mut f =
|
let f = create_temp_file(self.draft.to_string().unwrap().as_str().as_bytes(), None);
|
||||||
create_temp_file(self.draft.to_string().unwrap().as_str().as_bytes(), None);
|
|
||||||
//let mut f = Box::new(std::fs::File::create(&dir).unwrap());
|
//let mut f = Box::new(std::fs::File::create(&dir).unwrap());
|
||||||
|
|
||||||
// TODO: check exit status
|
// TODO: check exit status
|
||||||
|
|
|
@ -39,7 +39,7 @@ struct AccountMenuEntry {
|
||||||
|
|
||||||
trait ListingTrait {
|
trait ListingTrait {
|
||||||
fn coordinates(&self) -> (usize, usize, Option<EnvelopeHash>);
|
fn coordinates(&self) -> (usize, usize, Option<EnvelopeHash>);
|
||||||
fn set_coordinates(&mut self, (usize, usize, Option<EnvelopeHash>));
|
fn set_coordinates(&mut self, _: (usize, usize, Option<EnvelopeHash>));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -48,7 +48,7 @@ pub enum ListingComponent {
|
||||||
Threaded(ThreadListing),
|
Threaded(ThreadListing),
|
||||||
Compact(CompactListing),
|
Compact(CompactListing),
|
||||||
}
|
}
|
||||||
use ListingComponent::*;
|
use crate::ListingComponent::*;
|
||||||
|
|
||||||
impl ListingTrait for ListingComponent {
|
impl ListingTrait for ListingComponent {
|
||||||
fn coordinates(&self) -> (usize, usize, Option<EnvelopeHash>) {
|
fn coordinates(&self) -> (usize, usize, Option<EnvelopeHash>) {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use components::utilities::PageMovement;
|
use crate::components::utilities::PageMovement;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ impl MailboxView {
|
||||||
}
|
}
|
||||||
threads.thread_nodes()[&iter_ptr].message().unwrap()
|
threads.thread_nodes()[&iter_ptr].message().unwrap()
|
||||||
};
|
};
|
||||||
if !context.accounts[self.cursor_pos.0].contains_key(&i) {
|
if !context.accounts[self.cursor_pos.0].contains_key(i) {
|
||||||
debug!("key = {}", i);
|
debug!("key = {}", i);
|
||||||
debug!(
|
debug!(
|
||||||
"name = {} {}",
|
"name = {} {}",
|
||||||
|
@ -292,7 +292,7 @@ impl MailboxView {
|
||||||
}
|
}
|
||||||
threads.thread_nodes()[&iter_ptr].message().unwrap()
|
threads.thread_nodes()[&iter_ptr].message().unwrap()
|
||||||
};
|
};
|
||||||
if !context.accounts[self.cursor_pos.0].contains_key(&i) {
|
if !context.accounts[self.cursor_pos.0].contains_key(i) {
|
||||||
//debug!("key = {}", i);
|
//debug!("key = {}", i);
|
||||||
//debug!(
|
//debug!(
|
||||||
// "name = {} {}",
|
// "name = {} {}",
|
||||||
|
@ -326,7 +326,7 @@ impl MailboxView {
|
||||||
for x in x..min_width.0 {
|
for x in x..min_width.0 {
|
||||||
self.columns[0][(x, idx)].set_bg(bg_color);
|
self.columns[0][(x, idx)].set_bg(bg_color);
|
||||||
}
|
}
|
||||||
let (mut x, _) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
&strings.1,
|
&strings.1,
|
||||||
&mut self.columns[1],
|
&mut self.columns[1],
|
||||||
fg_color,
|
fg_color,
|
||||||
|
@ -460,7 +460,7 @@ impl MailboxView {
|
||||||
|
|
||||||
let (upper_left, bottom_right) = area;
|
let (upper_left, bottom_right) = area;
|
||||||
let grid = grid.unwrap();
|
let grid = grid.unwrap();
|
||||||
let (mut x, y) = upper_left;
|
let (mut x, _y) = upper_left;
|
||||||
for i in 0..self.columns.len() {
|
for i in 0..self.columns.len() {
|
||||||
let (width, height) = self.columns[i].size();
|
let (width, height) = self.columns[i].size();
|
||||||
if self.widths[i] == 0 {
|
if self.widths[i] == 0 {
|
||||||
|
@ -861,32 +861,28 @@ impl Component for MailboxView {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Action::ToggleThreadSnooze => {
|
Action::ToggleThreadSnooze => {
|
||||||
{
|
let account = &mut context.accounts[self.cursor_pos.0];
|
||||||
//FIXME NLL
|
let folder_hash = account[self.cursor_pos.1]
|
||||||
let account = &mut context.accounts[self.cursor_pos.0];
|
.as_ref()
|
||||||
let folder_hash = account[self.cursor_pos.1]
|
.map(|m| m.folder.hash())
|
||||||
.as_ref()
|
.unwrap();
|
||||||
.map(|m| m.folder.hash())
|
let threads = account.collection.threads.entry(folder_hash).or_default();
|
||||||
.unwrap();
|
let thread_group =
|
||||||
let threads = account.collection.threads.entry(folder_hash).or_default();
|
threads.thread_nodes()[&threads.root_set(self.cursor_pos.2)].thread_group();
|
||||||
let thread_group = threads.thread_nodes()
|
let thread_group = threads.find(thread_group);
|
||||||
[&threads.root_set(self.cursor_pos.2)]
|
/*let i = if let Some(i) = threads.thread_nodes[&thread_group].message() {
|
||||||
.thread_group();
|
i
|
||||||
let thread_group = threads.find(thread_group);
|
} else {
|
||||||
/*let i = if let Some(i) = threads.thread_nodes[&thread_group].message() {
|
let mut iter_ptr = threads.thread_nodes[&thread_group].children()[0];
|
||||||
i
|
while threads.thread_nodes()[&iter_ptr].message().is_none() {
|
||||||
} else {
|
iter_ptr = threads.thread_nodes()[&iter_ptr].children()[0];
|
||||||
let mut iter_ptr = threads.thread_nodes[&thread_group].children()[0];
|
}
|
||||||
while threads.thread_nodes()[&iter_ptr].message().is_none() {
|
threads.thread_nodes()[&iter_ptr].message().unwrap()
|
||||||
iter_ptr = threads.thread_nodes()[&iter_ptr].children()[0];
|
};*/
|
||||||
}
|
let root_node = threads.thread_nodes.entry(thread_group).or_default();
|
||||||
threads.thread_nodes()[&iter_ptr].message().unwrap()
|
let is_snoozed = root_node.snoozed();
|
||||||
};*/
|
root_node.set_snoozed(!is_snoozed);
|
||||||
let root_node = threads.thread_nodes.entry(thread_group).or_default();
|
//self.row_updates.push(i);
|
||||||
let is_snoozed = root_node.snoozed();
|
|
||||||
root_node.set_snoozed(!is_snoozed);
|
|
||||||
//self.row_updates.push(i);
|
|
||||||
}
|
|
||||||
self.refresh_mailbox(context);
|
self.refresh_mailbox(context);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,8 +246,7 @@ impl PlainListing {
|
||||||
1
|
1
|
||||||
};
|
};
|
||||||
// Populate `CellBuffer` with every entry.
|
// Populate `CellBuffer` with every entry.
|
||||||
let mut idx = 0;
|
for (idx, y) in (0..=self.length).enumerate() {
|
||||||
for y in 0..=self.length {
|
|
||||||
if idx >= self.length {
|
if idx >= self.length {
|
||||||
/* No more entries left, so fill the rest of the area with empty space */
|
/* No more entries left, so fill the rest of the area with empty space */
|
||||||
clear_area(&mut self.content, ((0, y), (MAX_COLS - 1, self.length)));
|
clear_area(&mut self.content, ((0, y), (MAX_COLS - 1, self.length)));
|
||||||
|
@ -280,7 +279,7 @@ impl PlainListing {
|
||||||
self.content[(x, idx)].set_bg(bg_color);
|
self.content[(x, idx)].set_bg(bg_color);
|
||||||
}
|
}
|
||||||
let mut _x = widths.0 + column_sep;
|
let mut _x = widths.0 + column_sep;
|
||||||
let (mut x, _) = write_string_to_grid(
|
let (x, _) = write_string_to_grid(
|
||||||
&rows[idx].2,
|
&rows[idx].2,
|
||||||
&mut self.content,
|
&mut self.content,
|
||||||
fg_color,
|
fg_color,
|
||||||
|
@ -317,8 +316,6 @@ impl PlainListing {
|
||||||
self.content[(x, y)].set_ch(' ');
|
self.content[(x, y)].set_ch(' ');
|
||||||
self.content[(x, y)].set_bg(bg_color);
|
self.content[(x, y)].set_bg(bg_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
idx += 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,7 +534,7 @@ impl Component for PlainListing {
|
||||||
coordinates.1,
|
coordinates.1,
|
||||||
self.local_collection[self.cursor_pos.2],
|
self.local_collection[self.cursor_pos.2],
|
||||||
);
|
);
|
||||||
self.view = Some(MailView::new(coordinates, None, None, context));
|
self.view = Some(MailView::new(coordinates, None, None));
|
||||||
}
|
}
|
||||||
self.view.as_mut().unwrap().draw(
|
self.view.as_mut().unwrap().draw(
|
||||||
grid,
|
grid,
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use components::utilities::PageMovement;
|
use crate::components::utilities::PageMovement;
|
||||||
|
|
||||||
const MAX_COLS: usize = 500;
|
const MAX_COLS: usize = 500;
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@ impl Component for ThreadListing {
|
||||||
(envelope.hash(), envelope.is_seen())
|
(envelope.hash(), envelope.is_seen())
|
||||||
};
|
};
|
||||||
if !is_seen {
|
if !is_seen {
|
||||||
let op = account.operation(&hash);
|
let op = account.operation(hash);
|
||||||
let envelope: &mut Envelope =
|
let envelope: &mut Envelope =
|
||||||
account.get_env_mut(&self.locations[self.cursor_pos.2]);
|
account.get_env_mut(&self.locations[self.cursor_pos.2]);
|
||||||
envelope.set_seen(op).unwrap();
|
envelope.set_seen(op).unwrap();
|
||||||
|
@ -533,7 +533,7 @@ impl Component for ThreadListing {
|
||||||
if let Some(ref mut v) = self.view {
|
if let Some(ref mut v) = self.view {
|
||||||
v.update(coordinates);
|
v.update(coordinates);
|
||||||
} else {
|
} else {
|
||||||
self.view = Some(MailView::new(coordinates, None, None, context));
|
self.view = Some(MailView::new(coordinates, None, None));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.view.as_mut().unwrap().draw(
|
self.view.as_mut().unwrap().draw(
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use linkify::{Link, LinkFinder};
|
use linkify::{Link, LinkFinder};
|
||||||
|
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
|
|
||||||
mod html;
|
mod html;
|
||||||
|
@ -86,7 +87,6 @@ impl MailView {
|
||||||
coordinates: (usize, usize, EnvelopeHash),
|
coordinates: (usize, usize, EnvelopeHash),
|
||||||
pager: Option<Pager>,
|
pager: Option<Pager>,
|
||||||
subview: Option<Box<Component>>,
|
subview: Option<Box<Component>>,
|
||||||
context: &mut Context,
|
|
||||||
) -> Self {
|
) -> Self {
|
||||||
MailView {
|
MailView {
|
||||||
coordinates,
|
coordinates,
|
||||||
|
@ -168,9 +168,10 @@ impl MailView {
|
||||||
v.extend(html_filter.wait_with_output().unwrap().stdout);
|
v.extend(html_filter.wait_with_output().unwrap().stdout);
|
||||||
} else {
|
} else {
|
||||||
context.replies.push_back(UIEvent::Notification(
|
context.replies.push_back(UIEvent::Notification(
|
||||||
Some(format!(
|
Some(
|
||||||
"Failed to find any application to use as html filter"
|
"Failed to find any application to use as html filter"
|
||||||
)),
|
.to_string(),
|
||||||
|
),
|
||||||
String::new(),
|
String::new(),
|
||||||
));
|
));
|
||||||
return;
|
return;
|
||||||
|
@ -282,7 +283,7 @@ impl Component for MailView {
|
||||||
|
|
||||||
let y: usize = {
|
let y: usize = {
|
||||||
let account = &mut context.accounts[self.coordinates.0];
|
let account = &mut context.accounts[self.coordinates.0];
|
||||||
if !account.contains_key(&self.coordinates.2) {
|
if !account.contains_key(self.coordinates.2) {
|
||||||
/* The envelope has been renamed or removed, so wait for the appropriate event to
|
/* The envelope has been renamed or removed, so wait for the appropriate event to
|
||||||
* arrive */
|
* arrive */
|
||||||
return;
|
return;
|
||||||
|
@ -292,11 +293,7 @@ impl Component for MailView {
|
||||||
(envelope.hash(), envelope.is_seen())
|
(envelope.hash(), envelope.is_seen())
|
||||||
};
|
};
|
||||||
if !is_seen {
|
if !is_seen {
|
||||||
let folder_hash = {
|
let op = account.operation(hash);
|
||||||
let mailbox = &mut account[self.coordinates.1].as_mut().unwrap();
|
|
||||||
mailbox.folder.hash()
|
|
||||||
};
|
|
||||||
let op = account.operation(&hash);
|
|
||||||
let envelope: &mut Envelope = &mut account.get_env_mut(&self.coordinates.2);
|
let envelope: &mut Envelope = &mut account.get_env_mut(&self.coordinates.2);
|
||||||
envelope.set_seen(op).unwrap();
|
envelope.set_seen(op).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -392,7 +389,7 @@ impl Component for MailView {
|
||||||
envelope
|
envelope
|
||||||
.references()
|
.references()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|r| r.to_string())
|
.map(std::string::ToString::to_string)
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join(", ")
|
.join(", ")
|
||||||
),
|
),
|
||||||
|
@ -421,7 +418,7 @@ impl Component for MailView {
|
||||||
let body = {
|
let body = {
|
||||||
let account = &mut context.accounts[self.coordinates.0];
|
let account = &mut context.accounts[self.coordinates.0];
|
||||||
let envelope: &Envelope = &account.get_env(&self.coordinates.2);
|
let envelope: &Envelope = &account.get_env(&self.coordinates.2);
|
||||||
let op = account.operation(&envelope.hash());
|
let op = account.operation(envelope.hash());
|
||||||
envelope.body(op)
|
envelope.body(op)
|
||||||
};
|
};
|
||||||
match self.mode {
|
match self.mode {
|
||||||
|
@ -446,7 +443,7 @@ impl Component for MailView {
|
||||||
let text = {
|
let text = {
|
||||||
let account = &mut context.accounts[self.coordinates.0];
|
let account = &mut context.accounts[self.coordinates.0];
|
||||||
let envelope: &Envelope = &account.get_env(&self.coordinates.2);
|
let envelope: &Envelope = &account.get_env(&self.coordinates.2);
|
||||||
let mut op = account.operation(&envelope.hash());
|
let mut op = account.operation(envelope.hash());
|
||||||
op.as_bytes()
|
op.as_bytes()
|
||||||
.map(|v| String::from_utf8_lossy(v).into_owned())
|
.map(|v| String::from_utf8_lossy(v).into_owned())
|
||||||
.unwrap_or_else(|e| e.to_string())
|
.unwrap_or_else(|e| e.to_string())
|
||||||
|
@ -618,7 +615,7 @@ impl Component for MailView {
|
||||||
{
|
{
|
||||||
let account = &mut context.accounts[self.coordinates.0];
|
let account = &mut context.accounts[self.coordinates.0];
|
||||||
let envelope: &Envelope = &account.get_env(&self.coordinates.2);
|
let envelope: &Envelope = &account.get_env(&self.coordinates.2);
|
||||||
let op = account.operation(&envelope.hash());
|
let op = account.operation(envelope.hash());
|
||||||
if let Some(u) = envelope.body(op).attachments().get(lidx) {
|
if let Some(u) = envelope.body(op).attachments().get(lidx) {
|
||||||
match u.content_type() {
|
match u.content_type() {
|
||||||
ContentType::MessageRfc822 => {
|
ContentType::MessageRfc822 => {
|
||||||
|
@ -657,7 +654,7 @@ impl Component for MailView {
|
||||||
let attachment_type = u.mime_type();
|
let attachment_type = u.mime_type();
|
||||||
let binary = query_default_app(&attachment_type);
|
let binary = query_default_app(&attachment_type);
|
||||||
if let Ok(binary) = binary {
|
if let Ok(binary) = binary {
|
||||||
let mut p = create_temp_file(&decode(u, None), None);
|
let p = create_temp_file(&decode(u, None), None);
|
||||||
Command::new(&binary)
|
Command::new(&binary)
|
||||||
.arg(p.path())
|
.arg(p.path())
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
|
@ -714,8 +711,8 @@ impl Component for MailView {
|
||||||
let account = &mut context.accounts[self.coordinates.0];
|
let account = &mut context.accounts[self.coordinates.0];
|
||||||
let envelope: &Envelope = &account.get_env(&self.coordinates.2);
|
let envelope: &Envelope = &account.get_env(&self.coordinates.2);
|
||||||
let finder = LinkFinder::new();
|
let finder = LinkFinder::new();
|
||||||
let op = account.operation(&envelope.hash());
|
let op = account.operation(envelope.hash());
|
||||||
let mut t = envelope.body(op).text().to_string();
|
let t = envelope.body(op).text().to_string();
|
||||||
let links: Vec<Link> = finder.links(&t).collect();
|
let links: Vec<Link> = finder.links(&t).collect();
|
||||||
if let Some(u) = links.get(lidx) {
|
if let Some(u) = links.get(lidx) {
|
||||||
u.as_str().to_string()
|
u.as_str().to_string()
|
||||||
|
@ -742,7 +739,7 @@ impl Component for MailView {
|
||||||
}
|
}
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
}
|
}
|
||||||
UIEvent::EnvelopeRename(old_hash, new_hash) => {
|
UIEvent::EnvelopeRename(old_hash, new_hash) if self.coordinates.2 == old_hash => {
|
||||||
self.coordinates.2 = new_hash;
|
self.coordinates.2 = new_hash;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
@ -336,7 +336,7 @@ impl Component for EnvelopeView {
|
||||||
let cursor_pos = if self.mode.is_attachment() {
|
let cursor_pos = if self.mode.is_attachment() {
|
||||||
Some(0)
|
Some(0)
|
||||||
} else {
|
} else {
|
||||||
self.pager.as_mut().map(|p| p.cursor_pos())
|
self.pager.as_ref().map(Pager::cursor_pos)
|
||||||
};
|
};
|
||||||
self.pager = Some(Pager::from_string(
|
self.pager = Some(Pager::from_string(
|
||||||
text,
|
text,
|
||||||
|
@ -439,7 +439,7 @@ impl Component for EnvelopeView {
|
||||||
let attachment_type = u.mime_type();
|
let attachment_type = u.mime_type();
|
||||||
let binary = query_default_app(&attachment_type);
|
let binary = query_default_app(&attachment_type);
|
||||||
if let Ok(binary) = binary {
|
if let Ok(binary) = binary {
|
||||||
let mut p = create_temp_file(&decode(u, None), None);
|
let p = create_temp_file(&decode(u, None), None);
|
||||||
Command::new(&binary)
|
Command::new(&binary)
|
||||||
.arg(p.path())
|
.arg(p.path())
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
|
@ -491,7 +491,7 @@ impl Component for EnvelopeView {
|
||||||
let url = {
|
let url = {
|
||||||
let envelope: &Envelope = self.wrapper.envelope();
|
let envelope: &Envelope = self.wrapper.envelope();
|
||||||
let finder = LinkFinder::new();
|
let finder = LinkFinder::new();
|
||||||
let mut t = envelope
|
let t = envelope
|
||||||
.body_bytes(self.wrapper.buffer())
|
.body_bytes(self.wrapper.buffer())
|
||||||
.text()
|
.text()
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
|
@ -132,7 +132,7 @@ impl Component for HtmlView {
|
||||||
// scripts)
|
// scripts)
|
||||||
let binary = query_default_app("text/html");
|
let binary = query_default_app("text/html");
|
||||||
if let Ok(binary) = binary {
|
if let Ok(binary) = binary {
|
||||||
let mut p = create_temp_file(&self.bytes, None);
|
let p = create_temp_file(&self.bytes, None);
|
||||||
Command::new(&binary)
|
Command::new(&binary)
|
||||||
.arg(p.path())
|
.arg(p.path())
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use components::utilities::PageMovement;
|
use crate::components::utilities::PageMovement;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
|
||||||
const INDENTATION_COLORS: &'static [u8] = &[
|
const INDENTATION_COLORS: &'static [u8] = &[
|
||||||
|
@ -916,7 +916,7 @@ impl Component for ThreadView {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
};
|
};
|
||||||
let envelope: &Envelope = &account.get_env(&i);
|
let envelope: &Envelope = &account.get_env(&i);
|
||||||
let op = account.operation(&envelope.hash());
|
let op = account.operation(envelope.hash());
|
||||||
debug!(
|
debug!(
|
||||||
"sending action edit for {}, {}",
|
"sending action edit for {}, {}",
|
||||||
envelope.message_id(),
|
envelope.message_id(),
|
||||||
|
|
|
@ -336,7 +336,7 @@ impl Pager {
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("Failed to start pager filter process");
|
.expect("Failed to start pager filter process");
|
||||||
{
|
{
|
||||||
let mut stdin = filter_child.stdin.as_mut().expect("failed to open stdin");
|
let stdin = filter_child.stdin.as_mut().expect("failed to open stdin");
|
||||||
stdin
|
stdin
|
||||||
.write_all(text.as_bytes())
|
.write_all(text.as_bytes())
|
||||||
.expect("Failed to write to stdin");
|
.expect("Failed to write to stdin");
|
||||||
|
|
|
@ -32,7 +32,7 @@ impl Debug for Field {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use Field::*;
|
use crate::Field::*;
|
||||||
|
|
||||||
impl Default for Field {
|
impl Default for Field {
|
||||||
fn default() -> Field {
|
fn default() -> Field {
|
||||||
|
@ -749,14 +749,14 @@ impl ScrollBar {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if self.show_arrows {
|
if self.show_arrows {
|
||||||
height = height - 2;
|
height -= height;
|
||||||
}
|
}
|
||||||
clear_area(grid, area);
|
clear_area(grid, area);
|
||||||
|
|
||||||
let visible_ratio: f32 = (std::cmp::min(visible_rows, length) as f32) / (length as f32);
|
let visible_ratio: f32 = (std::cmp::min(visible_rows, length) as f32) / (length as f32);
|
||||||
let scrollbar_height = std::cmp::max((visible_ratio * (height as f32)) as usize, 1);
|
let scrollbar_height = std::cmp::max((visible_ratio * (height as f32)) as usize, 1);
|
||||||
let scrollbar_offset = {
|
let scrollbar_offset = {
|
||||||
let mut temp = (((pos as f32) / (length as f32)) * (height as f32)) as usize;
|
let temp = (((pos as f32) / (length as f32)) * (height as f32)) as usize;
|
||||||
if temp + scrollbar_height >= height {
|
if temp + scrollbar_height >= height {
|
||||||
height - scrollbar_height
|
height - scrollbar_height
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -37,9 +37,9 @@ pub use self::shortcuts::*;
|
||||||
|
|
||||||
use self::default_vals::*;
|
use self::default_vals::*;
|
||||||
use self::notifications::NotificationsSettings;
|
use self::notifications::NotificationsSettings;
|
||||||
|
use crate::pager::PagerSettings;
|
||||||
use melib::conf::AccountSettings;
|
use melib::conf::AccountSettings;
|
||||||
use melib::error::*;
|
use melib::error::*;
|
||||||
use pager::PagerSettings;
|
|
||||||
|
|
||||||
use self::serde::{de, Deserialize, Deserializer};
|
use self::serde::{de, Deserialize, Deserializer};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -252,7 +252,7 @@ impl FileSettings {
|
||||||
.create_new(true)
|
.create_new(true)
|
||||||
.open(config_path.as_path())
|
.open(config_path.as_path())
|
||||||
.expect("Could not create config file.");
|
.expect("Could not create config file.");
|
||||||
file.write_all(include_str!("../../sample-config").as_bytes())
|
file.write_all(include_bytes!("../../sample-config"))
|
||||||
.expect("Could not write to config file.");
|
.expect("Could not write to config file.");
|
||||||
println!("Written config to {}", config_path.display());
|
println!("Written config to {}", config_path.display());
|
||||||
std::process::exit(1);
|
std::process::exit(1);
|
||||||
|
@ -365,23 +365,23 @@ where
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mod default_vals {
|
mod default_vals {
|
||||||
pub(in conf) fn false_val() -> bool {
|
pub(in crate::conf) fn false_val() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(in conf) fn true_val() -> bool {
|
pub(in crate::conf) fn true_val() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(in conf) fn zero_val() -> usize {
|
pub(in crate::conf) fn zero_val() -> usize {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(in conf) fn eighty_percent() -> usize {
|
pub(in crate::conf) fn eighty_percent() -> usize {
|
||||||
80
|
80
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(in conf) fn none() -> Option<String> {
|
pub(in crate::conf) fn none() -> Option<String> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ use melib::thread::ThreadHash;
|
||||||
use melib::AddressBook;
|
use melib::AddressBook;
|
||||||
use melib::StackVec;
|
use melib::StackVec;
|
||||||
|
|
||||||
|
use crate::types::UIEvent::{self, EnvelopeRemove, EnvelopeRename, EnvelopeUpdate, Notification};
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
@ -44,7 +45,6 @@ use std::mem;
|
||||||
use std::ops::{Index, IndexMut};
|
use std::ops::{Index, IndexMut};
|
||||||
use std::result;
|
use std::result;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use types::UIEvent::{self, EnvelopeRemove, EnvelopeRename, EnvelopeUpdate, Notification};
|
|
||||||
|
|
||||||
pub type Worker = Option<Async<(Result<FnvHashMap<EnvelopeHash, Envelope>>, Result<Mailbox>)>>;
|
pub type Worker = Option<Async<(Result<FnvHashMap<EnvelopeHash, Envelope>>, Result<Mailbox>)>>;
|
||||||
|
|
||||||
|
@ -215,17 +215,15 @@ impl Account {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
tree.sort_unstable_by_key(|f| ref_folders[&f.hash].name());
|
tree.sort_unstable_by_key(|f| ref_folders[&f.hash].name());
|
||||||
{
|
|
||||||
//FIXME: NLL
|
let mut stack: StackVec<Option<&FolderNode>> = StackVec::new();
|
||||||
let mut stack: StackVec<Option<&FolderNode>> = StackVec::new();
|
for n in tree.iter_mut() {
|
||||||
for n in tree.iter_mut() {
|
folders_order.push(n.hash);
|
||||||
folders_order.push(n.hash);
|
n.kids.sort_unstable_by_key(|f| ref_folders[&f.hash].name());
|
||||||
n.kids.sort_unstable_by_key(|f| ref_folders[&f.hash].name());
|
stack.extend(n.kids.iter().rev().map(Some));
|
||||||
stack.extend(n.kids.iter().rev().map(Some));
|
while let Some(Some(next)) = stack.pop() {
|
||||||
while let Some(Some(next)) = stack.pop() {
|
folders_order.push(next.hash);
|
||||||
folders_order.push(next.hash);
|
stack.extend(next.kids.iter().rev().map(Some));
|
||||||
stack.extend(next.kids.iter().rev().map(Some));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +232,7 @@ impl Account {
|
||||||
if data.exists() {
|
if data.exists() {
|
||||||
let reader = io::BufReader::new(fs::File::open(data).unwrap());
|
let reader = io::BufReader::new(fs::File::open(data).unwrap());
|
||||||
let result: result::Result<AddressBook, _> = serde_json::from_reader(reader);
|
let result: result::Result<AddressBook, _> = serde_json::from_reader(reader);
|
||||||
if let Ok(mut data_t) = result {
|
if let Ok(data_t) = result {
|
||||||
data_t
|
data_t
|
||||||
} else {
|
} else {
|
||||||
AddressBook::new(name.clone())
|
AddressBook::new(name.clone())
|
||||||
|
@ -284,10 +282,7 @@ impl Account {
|
||||||
.collect::<FnvHashMap<EnvelopeHash, Envelope>>()
|
.collect::<FnvHashMap<EnvelopeHash, Envelope>>()
|
||||||
});
|
});
|
||||||
let hash = folder.hash();
|
let hash = folder.hash();
|
||||||
let m = {
|
let m = Mailbox::new(folder, envelopes.as_ref().map_err(Clone::clone));
|
||||||
//FIXME NLL
|
|
||||||
Mailbox::new(folder, envelopes.as_ref().map_err(|e| e.clone()))
|
|
||||||
};
|
|
||||||
tx.send(AsyncStatus::Payload((envelopes, m)));
|
tx.send(AsyncStatus::Payload((envelopes, m)));
|
||||||
notify_fn.notify(hash);
|
notify_fn.notify(hash);
|
||||||
})))
|
})))
|
||||||
|
@ -318,36 +313,26 @@ impl Account {
|
||||||
}
|
}
|
||||||
RefreshEventKind::Create(envelope) => {
|
RefreshEventKind::Create(envelope) => {
|
||||||
let env_hash = envelope.hash();
|
let env_hash = envelope.hash();
|
||||||
|
let mailbox = mailbox!(&folder_hash, self.folders);
|
||||||
|
mailbox.insert(env_hash);
|
||||||
|
self.collection.insert(*envelope, folder_hash);
|
||||||
|
if self
|
||||||
|
.sent_folder
|
||||||
|
.as_ref()
|
||||||
|
.map(|h| *h == folder_hash)
|
||||||
|
.unwrap_or(false)
|
||||||
{
|
{
|
||||||
//FIXME NLL
|
self.collection.insert_reply(env_hash);
|
||||||
let mailbox = mailbox!(&folder_hash, self.folders);
|
|
||||||
mailbox.insert(env_hash);
|
|
||||||
self.collection.insert(*envelope, folder_hash);
|
|
||||||
if self
|
|
||||||
.sent_folder
|
|
||||||
.as_ref()
|
|
||||||
.map(|h| *h == folder_hash)
|
|
||||||
.unwrap_or(false)
|
|
||||||
{
|
|
||||||
self.collection.insert_reply(env_hash);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let ref_folders: FnvHashMap<FolderHash, Folder> = self.backend.folders();
|
let ref_folders: FnvHashMap<FolderHash, Folder> = self.backend.folders();
|
||||||
{
|
let folder_conf = &self.settings.folder_confs[&self.folder_names[&folder_hash]];
|
||||||
//FIXME NLL
|
if folder_conf.ignore.is_true() {
|
||||||
let folder_conf =
|
return None;
|
||||||
&self.settings.folder_confs[&self.folder_names[&folder_hash]];
|
|
||||||
if folder_conf.ignore.is_true() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
{
|
let (_, thread_node) = self.mail_and_thread(env_hash, folder_hash);
|
||||||
//FIXME NLL
|
if thread_node.snoozed() {
|
||||||
let (_, thread_node) = self.mail_and_thread(env_hash, folder_hash);
|
return None;
|
||||||
if thread_node.snoozed() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let env = self.get_env(&env_hash);
|
let env = self.get_env(&env_hash);
|
||||||
return Some(Notification(
|
return Some(Notification(
|
||||||
|
@ -494,18 +479,18 @@ impl Account {
|
||||||
pub fn get_env_mut(&mut self, h: &EnvelopeHash) -> &mut Envelope {
|
pub fn get_env_mut(&mut self, h: &EnvelopeHash) -> &mut Envelope {
|
||||||
self.collection.entry(*h).or_default()
|
self.collection.entry(*h).or_default()
|
||||||
}
|
}
|
||||||
pub fn contains_key(&self, h: &EnvelopeHash) -> bool {
|
pub fn contains_key(&self, h: EnvelopeHash) -> bool {
|
||||||
self.collection.contains_key(h)
|
self.collection.contains_key(&h)
|
||||||
}
|
}
|
||||||
pub fn operation(&self, h: &EnvelopeHash) -> Box<BackendOp> {
|
pub fn operation(&self, h: EnvelopeHash) -> Box<BackendOp> {
|
||||||
for mailbox in self.folders.values() {
|
for mailbox in self.folders.values() {
|
||||||
if let Some(Ok(m)) = mailbox {
|
if let Some(Ok(m)) = mailbox {
|
||||||
if m.envelopes.contains(h) {
|
if m.envelopes.contains(&h) {
|
||||||
return self.backend.operation(*h, m.folder.hash());
|
return self.backend.operation(h, m.folder.hash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug!("didn't find {}", *h);
|
debug!("didn't find {}", h);
|
||||||
std::dbg!(&self.folders);
|
std::dbg!(&self.folders);
|
||||||
std::dbg!(&self.collection.envelopes);
|
std::dbg!(&self.collection.envelopes);
|
||||||
unreachable!()
|
unreachable!()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use terminal::Key;
|
use crate::terminal::Key;
|
||||||
//use std::any::TypeId;
|
//use std::any::TypeId;
|
||||||
use fnv::FnvHashMap;
|
use fnv::FnvHashMap;
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@ pub use melib::mailbox::{SortField, SortOrder};
|
||||||
use nom::{digit, not_line_ending};
|
use nom::{digit, not_line_ending};
|
||||||
use std;
|
use std;
|
||||||
pub mod actions;
|
pub mod actions;
|
||||||
pub use actions::Action::{self, *};
|
pub use crate::actions::Action::{self, *};
|
||||||
pub use actions::ListingAction::{self, *};
|
pub use crate::actions::ListingAction::{self, *};
|
||||||
pub use actions::TabAction::{self, *};
|
pub use crate::actions::TabAction::{self, *};
|
||||||
|
|
||||||
named!(
|
named!(
|
||||||
usize_c<usize>,
|
usize_c<usize>,
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
* User actions that need to be handled by the UI
|
* User actions that need to be handled by the UI
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use components::Component;
|
use crate::components::Component;
|
||||||
pub use melib::mailbox::{SortField, SortOrder};
|
pub use melib::mailbox::{SortField, SortOrder};
|
||||||
use melib::thread::ThreadHash;
|
use melib::thread::ThreadHash;
|
||||||
use melib::EnvelopeHash;
|
use melib::EnvelopeHash;
|
||||||
|
|
|
@ -48,24 +48,24 @@ use std::collections::VecDeque;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod types;
|
mod types;
|
||||||
pub use types::*;
|
pub use crate::types::*;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod terminal;
|
mod terminal;
|
||||||
pub use terminal::*;
|
pub use crate::terminal::*;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod execute;
|
mod execute;
|
||||||
use execute::*;
|
use crate::execute::*;
|
||||||
|
|
||||||
pub mod state;
|
pub mod state;
|
||||||
pub use state::*;
|
pub use crate::state::*;
|
||||||
|
|
||||||
pub mod components;
|
pub mod components;
|
||||||
pub use components::*;
|
pub use crate::components::*;
|
||||||
|
|
||||||
pub mod conf;
|
pub mod conf;
|
||||||
pub use conf::*;
|
pub use crate::conf::*;
|
||||||
|
|
||||||
pub mod workers;
|
pub mod workers;
|
||||||
pub use workers::*;
|
pub use crate::workers::*;
|
||||||
|
|
|
@ -166,7 +166,7 @@ impl State {
|
||||||
* Create async channel to block the input-thread if we need to fork and stop it from reading
|
* Create async channel to block the input-thread if we need to fork and stop it from reading
|
||||||
* stdin, see get_events() for details
|
* stdin, see get_events() for details
|
||||||
* */
|
* */
|
||||||
let input_thread = chan::async();
|
let input_thread = chan::r#async();
|
||||||
let _stdout = std::io::stdout();
|
let _stdout = std::io::stdout();
|
||||||
_stdout.lock();
|
_stdout.lock();
|
||||||
let backends = Backends::new();
|
let backends = Backends::new();
|
||||||
|
@ -372,7 +372,6 @@ impl State {
|
||||||
/* Sort by x_start, ie upper_left corner's x coordinate */
|
/* Sort by x_start, ie upper_left corner's x coordinate */
|
||||||
areas.sort_by(|a, b| (a.0).0.partial_cmp(&(b.0).0).unwrap());
|
areas.sort_by(|a, b| (a.0).0.partial_cmp(&(b.0).0).unwrap());
|
||||||
/* draw each dirty area */
|
/* draw each dirty area */
|
||||||
let cols = self.cols;
|
|
||||||
let rows = self.rows;
|
let rows = self.rows;
|
||||||
for y in 0..rows {
|
for y in 0..rows {
|
||||||
let mut segment = None;
|
let mut segment = None;
|
||||||
|
@ -425,7 +424,6 @@ impl State {
|
||||||
write!(self.stdout(), "{}", termion::color::Fg(c.fg().as_termion())).unwrap();
|
write!(self.stdout(), "{}", termion::color::Fg(c.fg().as_termion())).unwrap();
|
||||||
}
|
}
|
||||||
write!(self.stdout(), "{}", c.ch()).unwrap();
|
write!(self.stdout(), "{}", c.ch()).unwrap();
|
||||||
let mut b = [0; 4];
|
|
||||||
if c.bg() != Color::Default {
|
if c.bg() != Color::Default {
|
||||||
write!(
|
write!(
|
||||||
self.stdout(),
|
self.stdout(),
|
||||||
|
@ -526,7 +524,7 @@ impl State {
|
||||||
pub fn try_wait_on_child(&mut self) -> Option<bool> {
|
pub fn try_wait_on_child(&mut self) -> Option<bool> {
|
||||||
let should_return_flag = match self.child {
|
let should_return_flag = match self.child {
|
||||||
Some(ForkType::NewDraft(_, ref mut c)) => {
|
Some(ForkType::NewDraft(_, ref mut c)) => {
|
||||||
let mut w = c.try_wait();
|
let w = c.try_wait();
|
||||||
match w {
|
match w {
|
||||||
Ok(Some(_)) => true,
|
Ok(Some(_)) => true,
|
||||||
Ok(None) => false,
|
Ok(None) => false,
|
||||||
|
@ -536,7 +534,7 @@ impl State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(ForkType::Generic(ref mut c)) => {
|
Some(ForkType::Generic(ref mut c)) => {
|
||||||
let mut w = c.try_wait();
|
let w = c.try_wait();
|
||||||
match w {
|
match w {
|
||||||
Ok(Some(_)) => true,
|
Ok(Some(_)) => true,
|
||||||
Ok(None) => false,
|
Ok(None) => false,
|
||||||
|
|
|
@ -22,7 +22,7 @@ extern crate serde;
|
||||||
use self::serde::de::Visitor;
|
use self::serde::de::Visitor;
|
||||||
use self::serde::{de, Deserialize, Deserializer};
|
use self::serde::{de, Deserialize, Deserializer};
|
||||||
extern crate unicode_segmentation;
|
extern crate unicode_segmentation;
|
||||||
use melib::grapheme_clusters::*;
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod position;
|
mod position;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use super::position::*;
|
use super::position::*;
|
||||||
|
|
||||||
use std::convert::From;
|
use std::convert::From;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ops::{Deref, DerefMut, Index, IndexMut};
|
use std::ops::{Deref, DerefMut, Index, IndexMut};
|
||||||
|
|
|
@ -72,7 +72,7 @@ pub enum Key {
|
||||||
|
|
||||||
impl fmt::Display for Key {
|
impl fmt::Display for Key {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
use Key::*;
|
use crate::Key::*;
|
||||||
match self {
|
match self {
|
||||||
F(n) => write!(f, "F{}", n),
|
F(n) => write!(f, "F{}", n),
|
||||||
Char('\t') => write!(f, "Tab"),
|
Char('\t') => write!(f, "Tab"),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use super::*;
|
use melib::Graphemes;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, PartialEq)]
|
#[derive(Debug, Clone, Default, PartialEq)]
|
||||||
pub struct UText {
|
pub struct UText {
|
||||||
|
|
|
@ -152,7 +152,7 @@ impl<T: Send> WorkQueue<T> {
|
||||||
|
|
||||||
impl WorkController {
|
impl WorkController {
|
||||||
pub fn new() -> WorkController {
|
pub fn new() -> WorkController {
|
||||||
let (new_jobs_tx, new_jobs_rx) = chan::async();
|
let (new_jobs_tx, new_jobs_rx) = chan::r#async();
|
||||||
// Create a new work queue to keep track of what work needs to be done.
|
// Create a new work queue to keep track of what work needs to be done.
|
||||||
// Note that the queue is internally mutable (or, rather, the Mutex is),
|
// Note that the queue is internally mutable (or, rather, the Mutex is),
|
||||||
// but this binding doesn't need to be mutable. This isn't unsound because
|
// but this binding doesn't need to be mutable. This isn't unsound because
|
||||||
|
@ -163,7 +163,7 @@ impl WorkController {
|
||||||
// Create a MPSC (Multiple Producer, Single Consumer) channel. Every worker
|
// Create a MPSC (Multiple Producer, Single Consumer) channel. Every worker
|
||||||
// is a producer, the main thread is a consumer; the producers put their
|
// is a producer, the main thread is a consumer; the producers put their
|
||||||
// work into the channel when it's done.
|
// work into the channel when it's done.
|
||||||
let (results_tx, results_rx) = chan::async();
|
let (results_tx, results_rx) = chan::r#async();
|
||||||
|
|
||||||
// Create a SyncFlag to share whether or not there are more jobs to be done.
|
// Create a SyncFlag to share whether or not there are more jobs to be done.
|
||||||
let (thread_end_tx, thread_end_rx) = chan::sync(::std::mem::size_of::<bool>());
|
let (thread_end_tx, thread_end_rx) = chan::sync(::std::mem::size_of::<bool>());
|
||||||
|
|
Loading…
Reference in New Issue