parent
d1d11356db
commit
ecb3fd7f3d
|
@ -37,12 +37,13 @@ use std::ops::Deref;
|
||||||
use fnv::FnvHashMap;
|
use fnv::FnvHashMap;
|
||||||
use std;
|
use std;
|
||||||
|
|
||||||
pub type BackendCreator = Box<Fn(&AccountSettings, Box<Fn(&str) -> bool>) -> Box<MailBackend>>;
|
pub type BackendCreator =
|
||||||
|
Box<dyn Fn(&AccountSettings, Box<dyn Fn(&str) -> bool>) -> Box<dyn MailBackend>>;
|
||||||
|
|
||||||
/// A hashmap containing all available mail backends.
|
/// A hashmap containing all available mail backends.
|
||||||
/// An abstraction over any available backends.
|
/// An abstraction over any available backends.
|
||||||
pub struct Backends {
|
pub struct Backends {
|
||||||
map: FnvHashMap<std::string::String, Box<Fn() -> BackendCreator>>,
|
map: FnvHashMap<std::string::String, Box<dyn Fn() -> BackendCreator>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Backends {
|
impl Default for Backends {
|
||||||
|
@ -78,7 +79,7 @@ impl Backends {
|
||||||
self.map[key]()
|
self.map[key]()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn register(&mut self, key: String, backend: Box<Fn() -> BackendCreator>) {
|
pub fn register(&mut self, key: String, backend: Box<dyn Fn() -> BackendCreator>) {
|
||||||
if self.map.contains_key(&key) {
|
if self.map.contains_key(&key) {
|
||||||
panic!("{} is an already registered backend", key);
|
panic!("{} is an already registered backend", key);
|
||||||
}
|
}
|
||||||
|
@ -116,9 +117,9 @@ impl RefreshEvent {
|
||||||
/// A `RefreshEventConsumer` is a boxed closure that must be used to consume a `RefreshEvent` and
|
/// A `RefreshEventConsumer` is a boxed closure that must be used to consume a `RefreshEvent` and
|
||||||
/// send it to a UI provided channel. We need this level of abstraction to provide an interface for
|
/// send it to a UI provided channel. We need this level of abstraction to provide an interface for
|
||||||
/// all users of mailbox refresh events.
|
/// all users of mailbox refresh events.
|
||||||
pub struct RefreshEventConsumer(Box<Fn(RefreshEvent) -> () + Send + Sync>);
|
pub struct RefreshEventConsumer(Box<dyn Fn(RefreshEvent) -> () + Send + Sync>);
|
||||||
impl RefreshEventConsumer {
|
impl RefreshEventConsumer {
|
||||||
pub fn new(b: Box<Fn(RefreshEvent) -> () + Send + Sync>) -> Self {
|
pub fn new(b: Box<dyn Fn(RefreshEvent) -> () + Send + Sync>) -> Self {
|
||||||
RefreshEventConsumer(b)
|
RefreshEventConsumer(b)
|
||||||
}
|
}
|
||||||
pub fn send(&self, r: RefreshEvent) {
|
pub fn send(&self, r: RefreshEvent) {
|
||||||
|
@ -126,7 +127,7 @@ impl RefreshEventConsumer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct NotifyFn(Box<Fn(FolderHash) -> () + Send + Sync>);
|
pub struct NotifyFn(Box<dyn Fn(FolderHash) -> () + Send + Sync>);
|
||||||
|
|
||||||
impl fmt::Debug for NotifyFn {
|
impl fmt::Debug for NotifyFn {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
@ -134,14 +135,14 @@ impl fmt::Debug for NotifyFn {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Box<Fn(FolderHash) -> () + Send + Sync>> for NotifyFn {
|
impl From<Box<dyn Fn(FolderHash) -> () + Send + Sync>> for NotifyFn {
|
||||||
fn from(kind: Box<Fn(FolderHash) -> () + Send + Sync>) -> Self {
|
fn from(kind: Box<dyn Fn(FolderHash) -> () + Send + Sync>) -> Self {
|
||||||
NotifyFn(kind)
|
NotifyFn(kind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NotifyFn {
|
impl NotifyFn {
|
||||||
pub fn new(b: Box<Fn(FolderHash) -> () + Send + Sync>) -> Self {
|
pub fn new(b: Box<dyn Fn(FolderHash) -> () + Send + Sync>) -> Self {
|
||||||
NotifyFn(b)
|
NotifyFn(b)
|
||||||
}
|
}
|
||||||
pub fn notify(&self, f: FolderHash) {
|
pub fn notify(&self, f: FolderHash) {
|
||||||
|
@ -164,10 +165,10 @@ pub trait MailBackend: ::std::fmt::Debug {
|
||||||
fn get(&mut self, folder: &Folder) -> Async<Result<Vec<Envelope>>>;
|
fn get(&mut self, folder: &Folder) -> Async<Result<Vec<Envelope>>>;
|
||||||
fn watch(&self, sender: RefreshEventConsumer) -> Result<()>;
|
fn watch(&self, sender: RefreshEventConsumer) -> Result<()>;
|
||||||
fn folders(&self) -> FnvHashMap<FolderHash, Folder>;
|
fn folders(&self) -> FnvHashMap<FolderHash, Folder>;
|
||||||
fn operation(&self, hash: EnvelopeHash, folder_hash: FolderHash) -> Box<BackendOp>;
|
fn operation(&self, hash: EnvelopeHash, folder_hash: FolderHash) -> Box<dyn BackendOp>;
|
||||||
|
|
||||||
fn save(&self, bytes: &[u8], folder: &str, flags: Option<Flag>) -> Result<()>;
|
fn save(&self, bytes: &[u8], folder: &str, flags: Option<Flag>) -> Result<()>;
|
||||||
fn folder_operation(&mut self, path: &str, op: FolderOperation) -> Result<()> {
|
fn folder_operation(&mut self, _path: &str, _op: FolderOperation) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,11 +235,11 @@ pub trait BackendOp: ::std::fmt::Debug + ::std::marker::Send {
|
||||||
/// Seen flag when fetching an envelope)
|
/// Seen flag when fetching an envelope)
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ReadOnlyOp {
|
pub struct ReadOnlyOp {
|
||||||
op: Box<BackendOp>,
|
op: Box<dyn BackendOp>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ReadOnlyOp {
|
impl ReadOnlyOp {
|
||||||
pub fn new(op: Box<BackendOp>) -> Box<BackendOp> {
|
pub fn new(op: Box<dyn BackendOp>) -> Box<dyn BackendOp> {
|
||||||
Box::new(ReadOnlyOp { op })
|
Box::new(ReadOnlyOp { op })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,7 @@ impl MailBackend for ImapType {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn operation(&self, hash: EnvelopeHash, _folder_hash: FolderHash) -> Box<BackendOp> {
|
fn operation(&self, hash: EnvelopeHash, _folder_hash: FolderHash) -> Box<dyn BackendOp> {
|
||||||
let (uid, folder_hash) = self.hash_index.lock().unwrap()[&hash];
|
let (uid, folder_hash) = self.hash_index.lock().unwrap()[&hash];
|
||||||
Box::new(ImapOp::new(
|
Box::new(ImapOp::new(
|
||||||
uid,
|
uid,
|
||||||
|
@ -400,7 +400,7 @@ macro_rules! exit_on_error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl ImapType {
|
impl ImapType {
|
||||||
pub fn new(s: &AccountSettings, is_subscribed: Box<Fn(&str) -> bool>) -> Self {
|
pub fn new(s: &AccountSettings, is_subscribed: Box<dyn Fn(&str) -> bool>) -> Self {
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::net::TcpStream;
|
use std::net::TcpStream;
|
||||||
debug!(s);
|
debug!(s);
|
||||||
|
|
|
@ -57,7 +57,7 @@ pub fn poll_with_examine(kit: ImapWatchKit) {
|
||||||
let mut response = String::with_capacity(8 * 1024);
|
let mut response = String::with_capacity(8 * 1024);
|
||||||
loop {
|
loop {
|
||||||
std::thread::sleep(std::time::Duration::from_millis(5 * 60 * 1000));
|
std::thread::sleep(std::time::Duration::from_millis(5 * 60 * 1000));
|
||||||
for (hash, folder) in &folders {
|
for folder in folders.values() {
|
||||||
examine_updates(folder, &sender, &mut conn, &hash_index, &uid_index);
|
examine_updates(folder, &sender, &mut conn, &hash_index, &uid_index);
|
||||||
}
|
}
|
||||||
let mut main_conn = main_conn.lock().unwrap();
|
let mut main_conn = main_conn.lock().unwrap();
|
||||||
|
@ -318,11 +318,6 @@ pub fn idle(kit: ImapWatchKit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug!("failure");
|
|
||||||
sender.send(RefreshEvent {
|
|
||||||
hash: folder_hash,
|
|
||||||
kind: RefreshEventKind::Failure(MeliError::new("conn_error")),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn examine_updates(
|
fn examine_updates(
|
||||||
|
|
|
@ -460,7 +460,7 @@ impl MailBackend for MaildirType {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn operation(&self, hash: EnvelopeHash, folder_hash: FolderHash) -> Box<BackendOp> {
|
fn operation(&self, hash: EnvelopeHash, folder_hash: FolderHash) -> Box<dyn BackendOp> {
|
||||||
Box::new(MaildirOp::new(hash, self.hash_indexes.clone(), folder_hash))
|
Box::new(MaildirOp::new(hash, self.hash_indexes.clone(), folder_hash))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,7 +529,7 @@ impl MailBackend for MaildirType {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MaildirType {
|
impl MaildirType {
|
||||||
pub fn new(settings: &AccountSettings, is_subscribed: Box<Fn(&str) -> bool>) -> Self {
|
pub fn new(settings: &AccountSettings, is_subscribed: Box<dyn Fn(&str) -> bool>) -> Self {
|
||||||
let mut folders: FnvHashMap<FolderHash, MaildirFolder> = Default::default();
|
let mut folders: FnvHashMap<FolderHash, MaildirFolder> = Default::default();
|
||||||
fn recurse_folders<P: AsRef<Path>>(
|
fn recurse_folders<P: AsRef<Path>>(
|
||||||
folders: &mut FnvHashMap<FolderHash, MaildirFolder>,
|
folders: &mut FnvHashMap<FolderHash, MaildirFolder>,
|
||||||
|
|
|
@ -242,7 +242,7 @@ impl BackendOp for MboxOp {
|
||||||
flags
|
flags
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_flag(&mut self, envelope: &mut Envelope, flag: Flag) -> Result<()> {
|
fn set_flag(&mut self, _envelope: &mut Envelope, _flag: Flag) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -526,7 +526,7 @@ impl MailBackend for MboxType {
|
||||||
.map(|(h, f)| (*h, f.clone() as Folder))
|
.map(|(h, f)| (*h, f.clone() as Folder))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
fn operation(&self, hash: EnvelopeHash, _folder_hash: FolderHash) -> Box<BackendOp> {
|
fn operation(&self, hash: EnvelopeHash, _folder_hash: FolderHash) -> Box<dyn BackendOp> {
|
||||||
let (offset, length) = {
|
let (offset, length) = {
|
||||||
let index = self.index.lock().unwrap();
|
let index = self.index.lock().unwrap();
|
||||||
index[&hash]
|
index[&hash]
|
||||||
|
@ -540,7 +540,7 @@ impl MailBackend for MboxType {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MboxType {
|
impl MboxType {
|
||||||
pub fn new(s: &AccountSettings, _is_subscribed: Box<Fn(&str) -> bool>) -> Self {
|
pub fn new(s: &AccountSettings, _is_subscribed: Box<dyn Fn(&str) -> bool>) -> Self {
|
||||||
let path = Path::new(s.root_folder.as_str());
|
let path = Path::new(s.root_folder.as_str());
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
panic!(
|
panic!(
|
||||||
|
|
|
@ -387,7 +387,7 @@ impl Envelope {
|
||||||
}
|
}
|
||||||
Err(MeliError::new("Couldn't parse mail."))
|
Err(MeliError::new("Couldn't parse mail."))
|
||||||
}
|
}
|
||||||
pub fn from_token(mut operation: Box<BackendOp>, hash: EnvelopeHash) -> Option<Envelope> {
|
pub fn from_token(mut operation: Box<dyn BackendOp>, hash: EnvelopeHash) -> Option<Envelope> {
|
||||||
let mut e = Envelope::new(hash);
|
let mut e = Envelope::new(hash);
|
||||||
e.flags = operation.fetch_flags();
|
e.flags = operation.fetch_flags();
|
||||||
if let Ok(bytes) = operation.as_bytes() {
|
if let Ok(bytes) = operation.as_bytes() {
|
||||||
|
@ -522,7 +522,7 @@ impl Envelope {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn populate_headers_from_token(&mut self, mut operation: Box<BackendOp>) -> Result<()> {
|
pub fn populate_headers_from_token(&mut self, mut operation: Box<dyn BackendOp>) -> Result<()> {
|
||||||
let headers = operation.fetch_headers()?;
|
let headers = operation.fetch_headers()?;
|
||||||
self.populate_headers(headers)
|
self.populate_headers(headers)
|
||||||
}
|
}
|
||||||
|
@ -563,7 +563,7 @@ impl Envelope {
|
||||||
let _strings: Vec<String> = self.to.iter().map(|a| format!("{}", a)).collect();
|
let _strings: Vec<String> = self.to.iter().map(|a| format!("{}", a)).collect();
|
||||||
_strings.join(", ")
|
_strings.join(", ")
|
||||||
}
|
}
|
||||||
pub fn bytes(&self, mut operation: Box<BackendOp>) -> Vec<u8> {
|
pub fn bytes(&self, mut operation: Box<dyn BackendOp>) -> Vec<u8> {
|
||||||
operation
|
operation
|
||||||
.as_bytes()
|
.as_bytes()
|
||||||
.map(|v| v.into())
|
.map(|v| v.into())
|
||||||
|
@ -608,7 +608,7 @@ impl Envelope {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn body(&self, mut operation: Box<BackendOp>) -> Attachment {
|
pub fn body(&self, mut operation: Box<dyn BackendOp>) -> Attachment {
|
||||||
debug!("searching body for {:?}", self.message_id_display());
|
debug!("searching body for {:?}", self.message_id_display());
|
||||||
let file = operation.as_bytes();
|
let file = operation.as_bytes();
|
||||||
self.body_bytes(file.unwrap())
|
self.body_bytes(file.unwrap())
|
||||||
|
@ -781,7 +781,7 @@ impl Envelope {
|
||||||
pub fn set_datetime(&mut self, new_val: chrono::DateTime<chrono::FixedOffset>) {
|
pub fn set_datetime(&mut self, new_val: chrono::DateTime<chrono::FixedOffset>) {
|
||||||
self.timestamp = new_val.timestamp() as UnixTimestamp;
|
self.timestamp = new_val.timestamp() as UnixTimestamp;
|
||||||
}
|
}
|
||||||
pub fn set_flag(&mut self, f: Flag, mut operation: Box<BackendOp>) -> Result<()> {
|
pub fn set_flag(&mut self, f: Flag, mut operation: Box<dyn BackendOp>) -> Result<()> {
|
||||||
self.flags.toggle(f);
|
self.flags.toggle(f);
|
||||||
operation.set_flag(self, f)?;
|
operation.set_flag(self, f)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -792,14 +792,14 @@ impl Envelope {
|
||||||
pub fn flags(&self) -> Flag {
|
pub fn flags(&self) -> Flag {
|
||||||
self.flags
|
self.flags
|
||||||
}
|
}
|
||||||
pub fn set_seen(&mut self, operation: Box<BackendOp>) -> Result<()> {
|
pub fn set_seen(&mut self, operation: Box<dyn BackendOp>) -> Result<()> {
|
||||||
if !self.flags.contains(Flag::SEEN) {
|
if !self.flags.contains(Flag::SEEN) {
|
||||||
self.set_flag(Flag::SEEN, operation)
|
self.set_flag(Flag::SEEN, operation)
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn set_unseen(&mut self, operation: Box<BackendOp>) -> Result<()> {
|
pub fn set_unseen(&mut self, operation: Box<dyn BackendOp>) -> Result<()> {
|
||||||
if self.flags.contains(Flag::SEEN) {
|
if self.flags.contains(Flag::SEEN) {
|
||||||
self.set_flag(Flag::SEEN, operation)
|
self.set_flag(Flag::SEEN, operation)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -441,7 +441,7 @@ fn decode_rfc822(_raw: &[u8]) -> Attachment {
|
||||||
builder.build()
|
builder.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
type Filter<'a> = Box<FnMut(&'a Attachment, &mut Vec<u8>) -> () + 'a>;
|
type Filter<'a> = Box<dyn 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> {
|
||||||
match a.content_type {
|
match a.content_type {
|
||||||
|
|
|
@ -113,7 +113,7 @@ impl str::FromStr for Draft {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Draft {
|
impl Draft {
|
||||||
pub fn edit(envelope: &Envelope, mut op: Box<BackendOp>) -> Self {
|
pub fn edit(envelope: &Envelope, mut op: Box<dyn BackendOp>) -> Self {
|
||||||
let mut ret = Draft::default();
|
let mut ret = Draft::default();
|
||||||
//TODO: Inform user if error
|
//TODO: Inform user if error
|
||||||
{
|
{
|
||||||
|
|
|
@ -247,7 +247,7 @@ pub fn headers_raw(input: &[u8]) -> IResult<&[u8], &[u8]> {
|
||||||
if input.is_empty() {
|
if input.is_empty() {
|
||||||
return IResult::Incomplete(Needed::Unknown);
|
return IResult::Incomplete(Needed::Unknown);
|
||||||
}
|
}
|
||||||
for (i, x) in input.iter().enumerate() {
|
for i in 0..input.len() {
|
||||||
if input[i..].starts_with(b"\n\n") {
|
if input[i..].starts_with(b"\n\n") {
|
||||||
return IResult::Done(&input[(i + 1)..], &input[0..=i]);
|
return IResult::Done(&input[(i + 1)..], &input[0..=i]);
|
||||||
} else if input[i..].starts_with(b"\r\n\r\n") {
|
} else if input[i..].starts_with(b"\r\n\r\n") {
|
||||||
|
|
|
@ -1107,6 +1107,7 @@ impl Threads {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
fn link_envelope(&mut self, envelope: &mut Envelope) {
|
fn link_envelope(&mut self, envelope: &mut Envelope) {
|
||||||
let t_idx: ThreadHash = {
|
let t_idx: ThreadHash = {
|
||||||
let m_id = envelope.message_id().raw();
|
let m_id = envelope.message_id().raw();
|
||||||
|
@ -1215,7 +1216,7 @@ impl Threads {
|
||||||
}
|
}
|
||||||
ref_ptr = parent_id;
|
ref_ptr = parent_id;
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
fn tree_insert_root(&mut self, new_id: ThreadHash, envelopes: &Envelopes) {
|
fn tree_insert_root(&mut self, new_id: ThreadHash, envelopes: &Envelopes) {
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub struct ContactList {
|
||||||
|
|
||||||
mode: ViewMode,
|
mode: ViewMode,
|
||||||
dirty: bool,
|
dirty: bool,
|
||||||
view: Option<Box<Component>>,
|
view: Option<Box<dyn Component>>,
|
||||||
id: ComponentId,
|
id: ComponentId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ pub struct Index {
|
||||||
dirty: bool,
|
dirty: bool,
|
||||||
state: IndexState,
|
state: IndexState,
|
||||||
|
|
||||||
content: Box<IndexContent>,
|
content: Box<dyn IndexContent>,
|
||||||
id: ComponentId,
|
id: ComponentId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,6 @@ impl Component for Index {
|
||||||
IndexState::Unfocused => {
|
IndexState::Unfocused => {
|
||||||
self.content.draw(grid, area, context);
|
self.content.draw(grid, area, context);
|
||||||
}
|
}
|
||||||
//IndexState::Search => unreachable!(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.dirty = false;
|
self.dirty = false;
|
||||||
|
|
|
@ -112,11 +112,6 @@ impl ListingTrait for CompactListing {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let i = self.get_envelope_under_cursor(idx, context);
|
let i = self.get_envelope_under_cursor(idx, context);
|
||||||
let account = &context.accounts[self.cursor_pos.0];
|
|
||||||
let is_seen = {
|
|
||||||
let root_envelope: &Envelope = &account.get_env(&i);
|
|
||||||
root_envelope.is_seen()
|
|
||||||
};
|
|
||||||
|
|
||||||
let fg_color = self.data_columns.columns[0][(0, idx)].fg();
|
let fg_color = self.data_columns.columns[0][(0, idx)].fg();
|
||||||
let bg_color = if self.cursor_pos.2 == idx {
|
let bg_color = if self.cursor_pos.2 == idx {
|
||||||
|
@ -128,7 +123,6 @@ impl ListingTrait for CompactListing {
|
||||||
};
|
};
|
||||||
|
|
||||||
let (upper_left, bottom_right) = area;
|
let (upper_left, bottom_right) = area;
|
||||||
let (width, height) = self.data_columns.columns[3].size();
|
|
||||||
change_colors(grid, area, fg_color, bg_color);
|
change_colors(grid, area, fg_color, bg_color);
|
||||||
let mut x = get_x(upper_left)
|
let mut x = get_x(upper_left)
|
||||||
+ self.data_columns.widths[0]
|
+ self.data_columns.widths[0]
|
||||||
|
|
|
@ -502,12 +502,8 @@ impl Component for ThreadListing {
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
let account = &mut context.accounts[self.cursor_pos.0];
|
let account = &mut context.accounts[self.cursor_pos.0];
|
||||||
let (hash, is_seen) = {
|
let envelope: &Envelope = &account.get_env(&self.locations[self.cursor_pos.2]);
|
||||||
let envelope: &Envelope =
|
envelope.is_seen()
|
||||||
&account.get_env(&self.locations[self.cursor_pos.2]);
|
|
||||||
(envelope.hash(), envelope.is_seen())
|
|
||||||
};
|
|
||||||
is_seen
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ impl ViewMode {
|
||||||
pub struct MailView {
|
pub struct MailView {
|
||||||
coordinates: (usize, usize, EnvelopeHash),
|
coordinates: (usize, usize, EnvelopeHash),
|
||||||
pager: Option<Pager>,
|
pager: Option<Pager>,
|
||||||
subview: Option<Box<Component>>,
|
subview: Option<Box<dyn Component>>,
|
||||||
dirty: bool,
|
dirty: bool,
|
||||||
mode: ViewMode,
|
mode: ViewMode,
|
||||||
expand_headers: bool,
|
expand_headers: bool,
|
||||||
|
@ -89,7 +89,7 @@ impl MailView {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
coordinates: (usize, usize, EnvelopeHash),
|
coordinates: (usize, usize, EnvelopeHash),
|
||||||
pager: Option<Pager>,
|
pager: Option<Pager>,
|
||||||
subview: Option<Box<Component>>,
|
subview: Option<Box<dyn Component>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
MailView {
|
MailView {
|
||||||
coordinates,
|
coordinates,
|
||||||
|
|
|
@ -48,7 +48,7 @@ impl ViewMode {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct EnvelopeView {
|
pub struct EnvelopeView {
|
||||||
pager: Option<Pager>,
|
pager: Option<Pager>,
|
||||||
subview: Option<Box<Component>>,
|
subview: Option<Box<dyn Component>>,
|
||||||
dirty: bool,
|
dirty: bool,
|
||||||
mode: ViewMode,
|
mode: ViewMode,
|
||||||
wrapper: EnvelopeWrapper,
|
wrapper: EnvelopeWrapper,
|
||||||
|
@ -69,7 +69,7 @@ impl EnvelopeView {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
wrapper: EnvelopeWrapper,
|
wrapper: EnvelopeWrapper,
|
||||||
pager: Option<Pager>,
|
pager: Option<Pager>,
|
||||||
subview: Option<Box<Component>>,
|
subview: Option<Box<dyn Component>>,
|
||||||
account_pos: usize,
|
account_pos: usize,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
EnvelopeView {
|
EnvelopeView {
|
||||||
|
|
|
@ -30,8 +30,8 @@ pub use self::widgets::*;
|
||||||
/// A horizontally split in half container.
|
/// A horizontally split in half container.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct HSplit {
|
pub struct HSplit {
|
||||||
top: Box<Component>,
|
top: Box<dyn Component>,
|
||||||
bottom: Box<Component>,
|
bottom: Box<dyn Component>,
|
||||||
show_divider: bool,
|
show_divider: bool,
|
||||||
ratio: usize, // bottom/whole height * 100
|
ratio: usize, // bottom/whole height * 100
|
||||||
id: ComponentId,
|
id: ComponentId,
|
||||||
|
@ -46,8 +46,8 @@ impl fmt::Display for HSplit {
|
||||||
|
|
||||||
impl HSplit {
|
impl HSplit {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
top: Box<Component>,
|
top: Box<dyn Component>,
|
||||||
bottom: Box<Component>,
|
bottom: Box<dyn Component>,
|
||||||
ratio: usize,
|
ratio: usize,
|
||||||
show_divider: bool,
|
show_divider: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -125,8 +125,8 @@ impl Component for HSplit {
|
||||||
/// A vertically split in half container.
|
/// A vertically split in half container.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct VSplit {
|
pub struct VSplit {
|
||||||
left: Box<Component>,
|
left: Box<dyn Component>,
|
||||||
right: Box<Component>,
|
right: Box<dyn Component>,
|
||||||
show_divider: bool,
|
show_divider: bool,
|
||||||
prev_visibility: (bool, bool),
|
prev_visibility: (bool, bool),
|
||||||
/// This is the width of the right container to the entire width.
|
/// This is the width of the right container to the entire width.
|
||||||
|
@ -143,8 +143,8 @@ impl fmt::Display for VSplit {
|
||||||
|
|
||||||
impl VSplit {
|
impl VSplit {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
left: Box<Component>,
|
left: Box<dyn Component>,
|
||||||
right: Box<Component>,
|
right: Box<dyn Component>,
|
||||||
ratio: usize,
|
ratio: usize,
|
||||||
show_divider: bool,
|
show_divider: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -602,7 +602,7 @@ impl Component for Pager {
|
||||||
/// Status bar.
|
/// Status bar.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct StatusBar {
|
pub struct StatusBar {
|
||||||
container: Box<Component>,
|
container: Box<dyn Component>,
|
||||||
status: String,
|
status: String,
|
||||||
notifications: VecDeque<String>,
|
notifications: VecDeque<String>,
|
||||||
ex_buffer: Field,
|
ex_buffer: Field,
|
||||||
|
@ -624,7 +624,7 @@ impl fmt::Display for StatusBar {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StatusBar {
|
impl StatusBar {
|
||||||
pub fn new(container: Box<Component>) -> Self {
|
pub fn new(container: Box<dyn Component>) -> Self {
|
||||||
StatusBar {
|
StatusBar {
|
||||||
container,
|
container,
|
||||||
status: String::with_capacity(256),
|
status: String::with_capacity(256),
|
||||||
|
@ -1120,7 +1120,7 @@ impl Component for Progress {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Tabbed {
|
pub struct Tabbed {
|
||||||
pinned: usize,
|
pinned: usize,
|
||||||
children: Vec<Box<Component>>,
|
children: Vec<Box<dyn Component>>,
|
||||||
cursor_pos: usize,
|
cursor_pos: usize,
|
||||||
|
|
||||||
show_shortcuts: bool,
|
show_shortcuts: bool,
|
||||||
|
@ -1130,7 +1130,7 @@ pub struct Tabbed {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tabbed {
|
impl Tabbed {
|
||||||
pub fn new(children: Vec<Box<Component>>) -> Self {
|
pub fn new(children: Vec<Box<dyn Component>>) -> Self {
|
||||||
let pinned = children.len();
|
let pinned = children.len();
|
||||||
Tabbed {
|
Tabbed {
|
||||||
pinned,
|
pinned,
|
||||||
|
@ -1194,7 +1194,7 @@ impl Tabbed {
|
||||||
|
|
||||||
context.dirty_areas.push_back(area);
|
context.dirty_areas.push_back(area);
|
||||||
}
|
}
|
||||||
pub fn add_component(&mut self, new: Box<Component>) {
|
pub fn add_component(&mut self, new: Box<dyn Component>) {
|
||||||
self.children.push(new);
|
self.children.push(new);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
use fnv::FnvHashMap;
|
use fnv::FnvHashMap;
|
||||||
|
|
||||||
type AutoCompleteFn = Box<Fn(&Context, &str) -> Vec<AutoCompleteEntry> + Send>;
|
type AutoCompleteFn = Box<dyn Fn(&Context, &str) -> Vec<AutoCompleteEntry> + Send>;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
enum FormFocus {
|
enum FormFocus {
|
||||||
|
|
|
@ -317,7 +317,7 @@ impl Account {
|
||||||
}
|
}
|
||||||
fn new_worker(
|
fn new_worker(
|
||||||
folder: Folder,
|
folder: Folder,
|
||||||
backend: &mut Box<MailBackend>,
|
backend: &mut Box<dyn MailBackend>,
|
||||||
notify_fn: Arc<NotifyFn>,
|
notify_fn: Arc<NotifyFn>,
|
||||||
) -> Worker {
|
) -> Worker {
|
||||||
let mailbox_handle = backend.get(&folder);
|
let mailbox_handle = backend.get(&folder);
|
||||||
|
@ -617,7 +617,7 @@ impl Account {
|
||||||
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<dyn BackendOp> {
|
||||||
for mailbox in self.folders.values() {
|
for mailbox in self.folders.values() {
|
||||||
match mailbox {
|
match mailbox {
|
||||||
MailboxEntry::Available(ref m) | MailboxEntry::Parsing(ref m, _, _) => {
|
MailboxEntry::Available(ref m) | MailboxEntry::Parsing(ref m, _, _) => {
|
||||||
|
|
|
@ -45,7 +45,7 @@ pub enum ListingAction {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum TabAction {
|
pub enum TabAction {
|
||||||
New(Option<Box<Component>>),
|
New(Option<Box<dyn Component>>),
|
||||||
NewDraft(usize, Option<Draft>),
|
NewDraft(usize, Option<Draft>),
|
||||||
Reply((usize, usize, usize), ThreadHash), // thread coordinates (account, mailbox, root_set idx) and thread hash
|
Reply((usize, usize, usize), ThreadHash), // thread coordinates (account, mailbox, root_set idx) and thread hash
|
||||||
Close,
|
Close,
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
/*! The application's state.
|
/*! The application's state.
|
||||||
|
|
||||||
The UI crate has an Box<Component>-Component-System design. The System part, is also the application's state, so they're both merged in the `State` struct.
|
The UI crate has an Box<dyn Component>-Component-System design. The System part, is also the application's state, so they're both merged in the `State` struct.
|
||||||
|
|
||||||
`State` owns all the Components of the UI. In the application's main event loop, input is handed to the state in the form of `UIEvent` objects which traverse the component graph. Components decide to handle each input or not.
|
`State` owns all the Components of the UI. In the application's main event loop, input is handed to the state in the form of `UIEvent` objects which traverse the component graph. Components decide to handle each input or not.
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ pub struct State {
|
||||||
stdout: Option<StateStdout>,
|
stdout: Option<StateStdout>,
|
||||||
child: Option<ForkType>,
|
child: Option<ForkType>,
|
||||||
pub mode: UIMode,
|
pub mode: UIMode,
|
||||||
components: Vec<Box<Component>>,
|
components: Vec<Box<dyn Component>>,
|
||||||
pub context: Context,
|
pub context: Context,
|
||||||
threads: FnvHashMap<thread::ThreadId, (chan::Sender<bool>, thread::JoinHandle<()>)>,
|
threads: FnvHashMap<thread::ThreadId, (chan::Sender<bool>, thread::JoinHandle<()>)>,
|
||||||
work_controller: WorkController,
|
work_controller: WorkController,
|
||||||
|
@ -477,7 +477,7 @@ impl State {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn register_component(&mut self, component: Box<Component>) {
|
pub fn register_component(&mut self, component: Box<dyn Component>) {
|
||||||
self.components.push(component);
|
self.components.push(component);
|
||||||
}
|
}
|
||||||
/// Convert user commands to actions/method calls.
|
/// Convert user commands to actions/method calls.
|
||||||
|
|
Loading…
Reference in New Issue