summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--melib/src/error.rs1
-rw-r--r--melib/src/mailbox.rs2
-rw-r--r--melib/src/mailbox/backends/maildir/backend.rs41
-rw-r--r--melib/src/mailbox/collection.rs12
-rw-r--r--melib/src/mailbox/email.rs2
-rw-r--r--melib/src/mailbox/email/attachments.rs2
-rw-r--r--melib/src/mailbox/email/compose.rs2
-rw-r--r--melib/src/mailbox/thread.rs4
-rw-r--r--src/bin.rs1
-rw-r--r--ui/src/components/contacts/contact_list.rs22
-rw-r--r--ui/src/components/mail/compose.rs25
-rw-r--r--ui/src/components/mail/listing.rs6
-rw-r--r--ui/src/components/mail/listing/compact.rs18
-rw-r--r--ui/src/components/mail/listing/plain.rs11
-rw-r--r--ui/src/components/mail/listing/thread.rs17
-rw-r--r--ui/src/components/mail/view.rs75
-rw-r--r--ui/src/components/mail/view/thread.rs72
-rw-r--r--ui/src/components/utilities.rs8
-rw-r--r--ui/src/conf/accounts.rs6
-rw-r--r--ui/src/state.rs4
-rw-r--r--ui/src/types.rs4
21 files changed, 208 insertions, 127 deletions
diff --git a/melib/src/error.rs b/melib/src/error.rs
index 12216b24..657dd38d 100644
--- a/melib/src/error.rs
+++ b/melib/src/error.rs
@@ -63,7 +63,6 @@ impl Into<String> for MeliError {
}
}
-
impl Error for MeliError {
fn description(&self) -> &str {
&self.details
diff --git a/melib/src/mailbox.rs b/melib/src/mailbox.rs
index a8054409..49cc35c6 100644
--- a/melib/src/mailbox.rs
+++ b/melib/src/mailbox.rs
@@ -29,8 +29,8 @@ pub mod email;
pub use self::email::*;
/* Mail backends. Currently only maildir is supported */
pub mod backends;
-use crate::error::Result;
use self::backends::Folder;
+use crate::error::Result;
pub mod thread;
pub use self::thread::{SortField, SortOrder, ThreadNode, Threads};
diff --git a/melib/src/mailbox/backends/maildir/backend.rs b/melib/src/mailbox/backends/maildir/backend.rs
index 1ae6c627..35e507fe 100644
--- a/melib/src/mailbox/backends/maildir/backend.rs
+++ b/melib/src/mailbox/backends/maildir/backend.rs
@@ -19,14 +19,14 @@
* along with meli. If not, see <http://www.gnu.org/licenses/>.
*/
-use super::{MaildirFolder, MaildirOp};
-use crate::async_workers::*;
-use crate::conf::AccountSettings;
-use crate::error::{MeliError, Result};
use super::{
BackendFolder, BackendOp, Folder, FolderHash, MailBackend, RefreshEvent, RefreshEventConsumer,
RefreshEventKind::*,
};
+use super::{MaildirFolder, MaildirOp};
+use crate::async_workers::*;
+use crate::conf::AccountSettings;
+use crate::error::{MeliError, Result};
use crate::mailbox::email::{Envelope, EnvelopeHash};
use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
@@ -36,7 +36,6 @@ use std::sync::mpsc::channel;
//use std::sync::mpsc::sync_channel;
//use std::sync::mpsc::SyncSender;
//use std::time::Duration;
-use std::thread;
use fnv::{FnvHashMap, FnvHasher};
use std::collections::hash_map::DefaultHasher;
use std::ffi::OsStr;
@@ -47,6 +46,7 @@ use std::ops::{Deref, DerefMut};
use std::path::{Component, Path, PathBuf};
use std::result;
use std::sync::{Arc, Mutex};
+use std::thread;
#[derive(Debug, Default)]
pub struct HashIndex {
@@ -344,13 +344,26 @@ eprintln!("DEBUG: hash {}, path: {} couldn't be parsed in `add_path_to_index`",
path.push("cur");
{
let mut rand_buf = [0u8; 16];
- let mut f = fs::File::open("/dev/urandom").expect("Could not open /dev/urandom for reading");
- f.read_exact(&mut rand_buf).expect("Could not read from /dev/urandom/");
+ let mut f = fs::File::open("/dev/urandom")
+ .expect("Could not open /dev/urandom for reading");
+ f.read_exact(&mut rand_buf)
+ .expect("Could not read from /dev/urandom/");
let mut hostn_buf = String::with_capacity(256);
- let mut f = fs::File::open("/etc/hostname").expect("Could not open /etc/hostname for reading");
- f.read_to_string(&mut hostn_buf).expect("Could not read from /etc/hostname");
- let timestamp = std::time::SystemTime::now().duration_since(std::time::SystemTime::UNIX_EPOCH).unwrap().as_millis();
- path.push(&format!("{}.{:x}_{}.{}:2,", timestamp, u128::from_be_bytes(rand_buf), std::process::id(), hostn_buf.trim()));
+ let mut f = fs::File::open("/etc/hostname")
+ .expect("Could not open /etc/hostname for reading");
+ f.read_to_string(&mut hostn_buf)
+ .expect("Could not read from /etc/hostname");
+ let timestamp = std::time::SystemTime::now()
+ .duration_since(std::time::SystemTime::UNIX_EPOCH)
+ .unwrap()
+ .as_millis();
+ path.push(&format!(
+ "{}.{:x}_{}.{}:2,",
+ timestamp,
+ u128::from_be_bytes(rand_buf),
+ std::process::id(),
+ hostn_buf.trim()
+ ));
}
if cfg!(feature = "debug_log") {
eprintln!("saving at {}", path.display());
@@ -363,8 +376,8 @@ eprintln!("DEBUG: hash {}, path: {} couldn't be parsed in `add_path_to_index`",
}
Err(MeliError::new(format!(
- "'{}' is not a valid folder.",
- folder
+ "'{}' is not a valid folder.",
+ folder
)))
}
}
@@ -409,7 +422,7 @@ impl MaildirType {
}
}
}
-
+
if folders.is_empty() {
recurse_folders(&mut folders, &path);
} else {
diff --git a/melib/src/mailbox/collection.rs b/melib/src/mailbox/collection.rs
index a44d895d..72bec79a 100644
--- a/melib/src/mailbox/collection.rs
+++ b/melib/src/mailbox/collection.rs
@@ -103,7 +103,11 @@ impl Collection {
env.set_hash(new_hash);
self.envelopes.insert(new_hash, env);
{
- if self.threads.update_envelope(old_hash, new_hash, &self.envelopes).is_ok() {
+ if self
+ .threads
+ .update_envelope(old_hash, new_hash, &self.envelopes)
+ .is_ok()
+ {
return;
}
}
@@ -119,7 +123,11 @@ impl Collection {
let new_hash = envelope.hash();
self.envelopes.insert(new_hash, envelope);
{
- if self.threads.update_envelope(old_hash, new_hash, &self.envelopes).is_ok() {
+ if self
+ .threads
+ .update_envelope(old_hash, new_hash, &self.envelopes)
+ .is_ok()
+ {
return;
}
}
diff --git a/melib/src/mailbox/email.rs b/melib/src/mailbox/email.rs
index 78f17ea8..86af2283 100644
--- a/melib/src/mailbox/email.rs
+++ b/melib/src/mailbox/email.rs
@@ -32,8 +32,8 @@ pub use crate::attachments::*;
pub mod parser;
use parser::BytesExt;
-use crate::error::{MeliError, Result};
use super::backends::BackendOp;
+use crate::error::{MeliError, Result};
use std::borrow::Cow;
use std::cmp::Ordering;
diff --git a/melib/src/mailbox/email/attachments.rs b/melib/src/mailbox/email/attachments.rs
index a3929012..ec126ca2 100644
--- a/melib/src/mailbox/email/attachments.rs
+++ b/melib/src/mailbox/email/attachments.rs
@@ -18,10 +18,10 @@
* You should have received a copy of the GNU General Public License
* along with meli. If not, see <http://www.gnu.org/licenses/>.
*/
-use data_encoding::BASE64_MIME;
use crate::mailbox::email::parser;
use crate::mailbox::email::parser::BytesExt;
use crate::mailbox::email::EnvelopeWrapper;
+use data_encoding::BASE64_MIME;
use std::fmt;
use std::str;
diff --git a/melib/src/mailbox/email/compose.rs b/melib/src/mailbox/email/compose.rs
index 9841c5c8..2c691647 100644
--- a/melib/src/mailbox/email/compose.rs
+++ b/melib/src/mailbox/email/compose.rs
@@ -1,7 +1,7 @@
use super::*;
+use crate::mailbox::backends::BackendOp;
use chrono::{DateTime, Local};
use data_encoding::BASE64_MIME;
-use crate::mailbox::backends::BackendOp;
use std::str;
mod mime;
diff --git a/melib/src/mailbox/thread.rs b/melib/src/mailbox/thread.rs
index 2a91b53c..c9a1c55c 100644
--- a/melib/src/mailbox/thread.rs
+++ b/melib/src/mailbox/thread.rs
@@ -1339,7 +1339,9 @@ fn node_build(
let mut has_unseen = if let Some(msg) = thread_nodes[idx].message {
!collection[&msg].is_seen()
- } else { false };
+ } else {
+ false
+ };
let mut child_vec: Vec<ThreadTree> = Vec::new();
thread_nodes[idx].len = thread_nodes[idx].children.len();
diff --git a/src/bin.rs b/src/bin.rs
index c90a13c9..f757a405 100644
--- a/src/bin.rs
+++ b/src/bin.rs
@@ -29,7 +29,6 @@ use std::alloc::System;
#[global_allocator]
static GLOBAL: System = System;
-
use ui;
pub use melib::*;
diff --git a/ui/src/components/contacts/contact_list.rs b/ui/src/components/contacts/contact_list.rs
index 8932650d..3554b5b5 100644
--- a/ui/src/components/contacts/contact_list.rs
+++ b/ui/src/components/contacts/contact_list.rs
@@ -74,7 +74,12 @@ impl ContactList {
if self.id_positions.capacity() < book.len() {
self.id_positions.reserve(book.len());
}
- let mut maxima = ("First Name".len(), "Last Name".len(), "E-mail".len(), "URL".len());
+ let mut maxima = (
+ "First Name".len(),
+ "Last Name".len(),
+ "E-mail".len(),
+ "URL".len(),
+ );
for c in book.values() {
self.id_positions.push(*c.id());
@@ -94,7 +99,7 @@ impl ContactList {
Color::Default,
((0, 0), (MAX_COLS - 1, self.length)),
false,
- );
+ );
write_string_to_grid(
"Last Name",
&mut self.content,
@@ -102,15 +107,15 @@ impl ContactList {
Color::Default,
((maxima.0, 0), (MAX_COLS - 1, self.length)),
false,
- );
+ );
write_string_to_grid(
"E-mail",
&mut self.content,
Color::Default,
Color::Default,
- (( maxima.1, 0), (MAX_COLS - 1, self.length)),
+ ((maxima.1, 0), (MAX_COLS - 1, self.length)),
false,
- );
+ );
write_string_to_grid(
"URL",
&mut self.content,
@@ -118,7 +123,7 @@ impl ContactList {
Color::Default,
((maxima.2, 0), (MAX_COLS - 1, self.length)),
false,
- );
+ );
for (i, c) in book.values().enumerate() {
self.id_positions.push(*c.id());
@@ -143,12 +148,13 @@ impl ContactList {
&mut self.content,
Color::Default,
Color::Default,
- (( maxima.1, i + 1), (MAX_COLS - 1, self.length)),
+ ((maxima.1, i + 1), (MAX_COLS - 1, self.length)),
false,
);
write_string_to_grid(
c.url(),
- &mut self.content, Color::Default,
+ &mut self.content,
+ Color::Default,
Color::Default,
((maxima.2, i + 1), (MAX_COLS - 1, self.length)),
false,
diff --git a/ui/src/components/mail/compose.rs b/ui/src/components/mail/compose.rs
index ac1f2929..268bd444 100644
--- a/ui/src/components/mail/compose.rs
+++ b/ui/src/components/mail/compose.rs
@@ -426,7 +426,7 @@ impl Component for Composer {
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
match (&mut self.mode, &mut self.reply_context, &event.event_type) {
// don't pass Reply command to thread view in reply_context
- (_, _, UIEventType::Input(Key::Char('R'))) => {},
+ (_, _, UIEventType::Input(Key::Char('R'))) => {}
(ViewMode::Overview, Some((_, ref mut view)), _) => {
if view.process_event(event, context) {
self.dirty = true;
@@ -501,7 +501,10 @@ impl Component for Composer {
}
context.replies.push_back(UIEvent {
id: 0,
- event_type: UIEventType::Notification(Some("Could not save draft.".into()), e.into())
+ event_type: UIEventType::Notification(
+ Some("Could not save draft.".into()),
+ e.into(),
+ ),
});
}
context.replies.push_back(UIEvent {
@@ -607,8 +610,7 @@ impl Component for Composer {
fn get_shortcuts(&self, context: &Context) -> ShortcutMap {
let mut map = if self.mode.is_overview() {
- self.pager
- .get_shortcuts(context)
+ self.pager.get_shortcuts(context)
} else {
Default::default()
};
@@ -619,21 +621,12 @@ impl Component for Composer {
}
if self.mode.is_overview() {
- map.insert(
- "Switch to edit mode",
- Key::Char('o')
- );
+ map.insert("Switch to edit mode", Key::Char('o'));
}
if self.mode.is_edit() {
- map.insert(
- "Switch to overview",
- Key::Char('v')
- );
+ map.insert("Switch to overview", Key::Char('v'));
}
- map.insert(
- "Edit in $EDITOR",
- Key::Char('e')
- );
+ map.insert("Edit in $EDITOR", Key::Char('e'));
map
}
diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs
index 3f538483..9e2371d7 100644
--- a/ui/src/components/mail/listing.rs
+++ b/ui/src/components/mail/listing.rs
@@ -83,7 +83,7 @@ impl Component for Listing {
Listing::Plain(_) => {
return true;
}
- Listing::Threaded(l) => {
+ Listing::Threaded(l) => {
let mut new_l = PlainListing::default();
new_l.set_coordinates(l.coordinates());
new_l
@@ -102,7 +102,7 @@ impl Component for Listing {
Listing::Threaded(_) => {
return true;
}
- Listing::Plain(l) => {
+ Listing::Plain(l) => {
let mut new_l = ThreadListing::default();
new_l.set_coordinates(l.coordinates());
new_l
@@ -121,7 +121,7 @@ impl Component for Listing {
Listing::Compact(_) => {
return true;
}
- Listing::Threaded(l) => {
+ Listing::Threaded(l) => {
let mut new_l = CompactListing::default();
new_l.set_coordinates(l.coordinates());
new_l
diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs
index 17ab9e54..a748c372 100644
--- a/ui/src/components/mail/listing/compact.rs
+++ b/ui/src/components/mail/listing/compact.rs
@@ -275,7 +275,8 @@ impl CompactListing {
/// Draw the list of `Envelope`s.
fn draw_list(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
- if self.cursor_pos.1 != self.new_cursor_pos.1 || self.cursor_pos.0 != self.new_cursor_pos.0 {
+ if self.cursor_pos.1 != self.new_cursor_pos.1 || self.cursor_pos.0 != self.new_cursor_pos.0
+ {
self.refresh_mailbox(context);
}
let upper_left = upper_left!(area);
@@ -484,11 +485,15 @@ impl Component for CompactListing {
UIEventType::RefreshMailbox(_) => {
self.dirty = true;
}
- UIEventType::MailboxUpdate((ref idxa, ref idxf)) if *idxa == self.new_cursor_pos.0 && *idxf == self.new_cursor_pos.1 => {
+ UIEventType::MailboxUpdate((ref idxa, ref idxf))
+ if *idxa == self.new_cursor_pos.0 && *idxf == self.new_cursor_pos.1 =>
+ {
self.refresh_mailbox(context);
self.set_dirty();
}
- UIEventType::StartupCheck(ref f) if context.mailbox_hashes[f] == (self.new_cursor_pos.0, self.new_cursor_pos.1) => {
+ UIEventType::StartupCheck(ref f)
+ if context.mailbox_hashes[f] == (self.new_cursor_pos.0, self.new_cursor_pos.1) =>
+ {
self.refresh_mailbox(context);
self.set_dirty();
}
@@ -534,7 +539,12 @@ impl Component for CompactListing {
false
}
fn is_dirty(&self) -> bool {
- self.dirty || if self.unfocused { self.view.is_dirty() } else { false }
+ self.dirty
+ || if self.unfocused {
+ self.view.is_dirty()
+ } else {
+ false
+ }
}
fn set_dirty(&mut self) {
if self.unfocused {
diff --git a/ui/src/components/mail/listing/plain.rs b/ui/src/components/mail/listing/plain.rs
index 16368f95..27801887 100644
--- a/ui/src/components/mail/listing/plain.rs
+++ b/ui/src/components/mail/listing/plain.rs
@@ -252,7 +252,8 @@ impl PlainListing {
/// Draw the list of `Envelope`s.
fn draw_list(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
- if self.cursor_pos.1 != self.new_cursor_pos.1 || self.cursor_pos.0 != self.new_cursor_pos.0 {
+ if self.cursor_pos.1 != self.new_cursor_pos.1 || self.cursor_pos.0 != self.new_cursor_pos.0
+ {
self.refresh_mailbox(context);
}
let upper_left = upper_left!(area);
@@ -502,11 +503,15 @@ impl Component for PlainListing {
self.dirty = true;
self.view = None;
}
- UIEventType::MailboxUpdate((ref idxa, ref idxf)) if *idxa == self.new_cursor_pos.0 && *idxf == self.new_cursor_pos.1 => {
+ UIEventType::MailboxUpdate((ref idxa, ref idxf))
+ if *idxa == self.new_cursor_pos.0 && *idxf == self.new_cursor_pos.1 =>
+ {
self.refresh_mailbox(context);
self.set_dirty();
}
- UIEventType::StartupCheck(ref f) if context.mailbox_hashes[f] == (self.new_cursor_pos.0, self.new_cursor_pos.1) => {
+ UIEventType::StartupCheck(ref f)
+ if context.mailbox_hashes[f] == (self.new_cursor_pos.0, self.new_cursor_pos.1) =>
+ {
self.refresh_mailbox(context);
self.set_dirty();
}
diff --git a/ui/src/components/mail/listing/thread.rs b/ui/src/components/mail/listing/thread.rs
index 029e5a1c..d1f55aba 100644
--- a/ui/src/components/mail/listing/thread.rs
+++ b/ui/src/components/mail/listing/thread.rs
@@ -48,7 +48,11 @@ pub struct ThreadListing {
impl ListingTrait for ThreadListing {
fn coordinates(&self) -> (usize, usize, Option<EnvelopeHash>) {
- (self.cursor_pos.0, self.cursor_pos.1, Some(self.locations[self.cursor_pos.2]))
+ (
+ self.cursor_pos.0,
+ self.cursor_pos.1,
+ Some(self.locations[self.cursor_pos.2]),
+ )
}
fn set_coordinates(&mut self, coordinates: (usize, usize, Option<EnvelopeHash>)) {
self.new_cursor_pos = (coordinates.0, coordinates.1, 0);
@@ -291,7 +295,8 @@ impl ThreadListing {
/// Draw the list of `Envelope`s.
fn draw_list(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
- if self.cursor_pos.1 != self.new_cursor_pos.1 || self.cursor_pos.0 != self.new_cursor_pos.0 {
+ if self.cursor_pos.1 != self.new_cursor_pos.1 || self.cursor_pos.0 != self.new_cursor_pos.0
+ {
self.refresh_mailbox(context);
}
let upper_left = upper_left!(area);
@@ -660,11 +665,15 @@ impl Component for ThreadListing {
self.dirty = true;
self.view = None;
}
- UIEventType::MailboxUpdate((ref idxa, ref idxf)) if *idxa == self.new_cursor_pos.0 && *idxf == self.new_cursor_pos.1 => {
+ UIEventType::MailboxUpdate((ref idxa, ref idxf))
+ if *idxa == self.new_cursor_pos.0 && *idxf == self.new_cursor_pos.1 =>
+ {
self.refresh_mailbox(context);
self.set_dirty();
}
- UIEventType::StartupCheck(ref f) if context.mailbox_hashes[f] == (self.new_cursor_pos.0, self.new_cursor_pos.1) => {
+ UIEventType::StartupCheck(ref f)
+ if context.mailbox_hashes[f] == (self.new_cursor_pos.0, self.new_cursor_pos.1) =>
+ {
self.refresh_mailbox(context);
self.set_dirty();
}
diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs
index 5e74ecfe..d2549330 100644
--- a/ui/src/components/mail/view.rs
+++ b/ui/src/components/mail/view.rs
@@ -88,10 +88,7 @@ impl MailView {
let account = &mut context.accounts[coordinates.0];
let (hash, is_seen) = {
let mailbox = &mut account[coordinates.1].as_mut().unwrap();
- let envelope: &mut Envelope = &mut mailbox
- .collection
- .entry(coordinates.2)
- .or_default();
+ let envelope: &mut Envelope = &mut mailbox.collection.entry(coordinates.2).or_default();
(envelope.hash(), envelope.is_seen())
};
if !is_seen {
@@ -104,10 +101,7 @@ impl MailView {
backend.operation(hash, folder_hash)
};
let mailbox = &mut account[coordinates.1].as_mut().unwrap();
- let envelope: &mut Envelope = &mut mailbox
- .collection
- .entry(coordinates.2)
- .or_default();
+ let envelope: &mut Envelope = &mut mailbox.collection.entry(coordinates.2).or_default();
envelope.set_seen(op).unwrap();
}
MailView {
@@ -428,34 +422,37 @@ impl Component for MailView {
if let ViewMode::ContactSelector(_) = self.mode {
if let ViewMode::ContactSelector(s) =
std::mem::replace(&mut self.mode, ViewMode::Normal)
+ {
+ let account = &mut context.accounts[self.coordinates.0];
+ let mut results = Vec::new();
{
- let account = &mut context.accounts[self.coordinates.0];
- let mut results = Vec::new();
- {
- let mailbox = &account[self.coordinates.1]
- .as_ref()
- .unwrap();
- let envelope: &Envelope = &mailbox.collection[&self.coordinates.2];
- for c in s.collect() {
- let c = usize::from_ne_bytes({
- [c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]]
- });
- for (idx, env) in envelope.from().iter().chain(envelope.to().iter()).enumerate() {
- if idx != c {
- continue;
- }
-
- let mut new_card: Card = Card::new();
- new_card.set_email(env.get_email());
- new_card.set_lastname(env.get_display_name());
- results.push(new_card);
+ let mailbox = &account[self.coordinates.1].as_ref().unwrap();
+ let envelope: &Envelope = &mailbox.collection[&self.coordinates.2];
+ for c in s.collect() {
+ let c = usize::from_ne_bytes({
+ [c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]]
+ });
+ for (idx, env) in envelope
+ .from()
+ .iter()
+ .chain(envelope.to().iter())
+ .enumerate()
+ {
+ if idx != c {
+ continue;
}
+
+ let mut new_card: Card = Card::new();
+ new_card.set_email(env.get_email());
+ new_card.set_lastname(env.get_display_name());
+ results.push(new_card);
}
}
- for c in results {
- account.address_book.add_card(c);
- }
}
+ for c in results {
+ account.address_book.add_card(c);
+ }
+ }
return true;
}
let accounts = &context.accounts;
@@ -465,11 +462,13 @@ impl Component for MailView {
let envelope: &Envelope = &mailbox.collection[&self.coordinates.2];
let mut entries = Vec::new();
- for (idx, env) in envelope.from().iter().chain(envelope.to().iter()).enumerate() {
- entries.push((
- idx.to_ne_bytes().to_vec(),
- format!("{}", env),
- ));
+ for (idx, env) in envelope
+ .from()
+ .iter()
+ .chain(envelope.to().iter())
+ .enumerate()
+ {
+ entries.push((idx.to_ne_bytes().to_vec(), format!("{}", env)));
}
self.mode = ViewMode::ContactSelector(Selector::new(entries, true));
self.dirty = true;
@@ -651,7 +650,9 @@ impl Component for MailView {
}
self.dirty = true;
}
- UIEventType::EnvelopeRename(_, old_hash, new_hash) if old_hash == self.coordinates.2 => {
+ UIEventType::EnvelopeRename(_, old_hash, new_hash)
+ if old_hash == self.coordinates.2 =>
+ {
self.coordinates.2 = new_hash;
self.set_dirty();
}
diff --git a/ui/src/components/mail/view/thread.rs b/ui/src/components/mail/view/thread.rs
index dfad1fd2..2edb0ed3 100644
--- a/ui/src/components/mail/view/thread.rs
+++ b/ui/src/components/mail/view/thread.rs
@@ -79,9 +79,11 @@ impl ThreadView {
if self.entries.is_empty() {
return;
}
- let old_focused_entry = if self.entries.len() > self.cursor_pos {
+ let old_focused_entry = if self.entries.len() > self.cursor_pos {
Some(self.entries.remove(self.cursor_pos))
- } else { None };
+ } else {
+ None
+ };
let old_expanded_entry = if self.entries.len() > self.expanded_pos {
Some(self.entries.remove(self.expanded_pos))
@@ -93,21 +95,24 @@ impl ThreadView {
let expanded_pos = self.expanded_pos;
self.initiate(Some(expanded_pos), context);
if let Some(old_focused_entry) = old_focused_entry {
- if let Some(new_entry_idx) = self.entries.iter().position(
- |e| e.msg_idx == old_focused_entry.msg_idx ||
- (e.index.1 == old_focused_entry.index.1 && e.index.2 == old_focused_entry.index.2)) {
+ if let Some(new_entry_idx) = self.entries.iter().position(|e| {
+ e.msg_idx == old_focused_entry.msg_idx
+ || (e.index.1 == old_focused_entry.index.1
+ && e.index.2 == old_focused_entry.index.2)
+ }) {
self.cursor_pos = new_entry_idx;
}
}
if let Some(old_expanded_entry) = old_expanded_entry {
- if let Some(new_entry_idx) = self.entries.iter().position(
- |e| e.msg_idx == old_expanded_entry.msg_idx ||
- (e.index.1 == old_expanded_entry.index.1 && e.index.2 == old_expanded_entry.index.2)) {
+ if let Some(new_entry_idx) = self.entries.iter().position(|e| {
+ e.msg_idx == old_expanded_entry.msg_idx
+ || (e.index.1 == old_expanded_entry.index.1
+ && e.index.2 == old_expanded_entry.index.2)
+ }) {
self.expanded_pos = new_entry_idx;
}
}
self.set_dirty();
-
}
fn initiate(&mut self, expanded_idx: Option<usize>, context: &Context) {
/* stack to push thread messages in order in order to pop and print them later */
@@ -183,12 +188,14 @@ impl ThreadView {
if content[index].ch() == ' ' {
let mut ctr = 1;
while content.get(e.index.0 * 4 + ctr, 2 * y - 1).is_some() {
- if content[(e.index.0 * 4 + ctr, 2 * y - 1)].ch() != ' ' { break; }
+ if content[(e.index.0 * 4 + ctr, 2 * y - 1)].ch() != ' ' {
+ break;
+ }
set_and_join_box(
&mut content,
(e.index.0 * 4 + ctr, 2 * y - 1),
HORZ_BOUNDARY,
- );
+ );
ctr += 1;
}
set_and_join_box(&mut content, index, HORZ_BOUNDARY);
@@ -197,11 +204,19 @@ impl ThreadView {
write_string_to_grid(
&strings[y],
&mut content,
- if e.seen { Color::Default } else { Color::Byte(0) },
- if e.seen { Color::Default } else { Color::Byte(251) },
+ if e.seen {
+ Color::Default
+ } else {
+ Color::Byte(0)
+ },
+ if e.seen {
+ Color::Default
+ } else {
+ Color::Byte(251)
+ },
((e.index.0 * 4 + 1, 2 * y), (width - 1, height - 1)),
true,
- );
+ );
if let Some(len) = highlight_reply_subjects[y] {
let index = e.index.0 * 4 + 1 + strings[y].len() - len;
let area = ((index, 2 * y), (width - 2, 2 * y));
@@ -225,12 +240,14 @@ impl ThreadView {
if content[index].ch() == ' ' {
let mut ctr = 1;
while content.get(e.index.0 * 4 + ctr, 2 * y - 1).is_some() {
- if content[(e.index.0 * 4 + ctr, 2 * y - 1)].ch() != ' ' { break; }
+ if content[(e.index.0 * 4 + ctr, 2 * y - 1)].ch() != ' ' {
+ break;
+ }
set_and_join_box(
&mut content,
(e.index.0 * 4 + ctr, 2 * y - 1),
HORZ_BOUNDARY,
- );
+ );
ctr += 1;
}
set_and_join_box(&mut content, index, HORZ_BOUNDARY);
@@ -239,11 +256,19 @@ impl ThreadView {
write_string_to_grid(
&strings[y],
&mut content,
- if e.seen { Color::Default } else { Color::Byte(0) },
- if e.seen { Color::Default } else { Color::Byte(251) },
+ if e.seen {
+ Color::Default
+ } else {
+ Color::Byte(0)
+ },
+ if e.seen {
+ Color::Default
+ } else {
+ Color::Byte(251)
+ },
((e.index.0 * 4 + 1, 2 * y), (width - 1, height - 1)),
true,
- );
+ );
if let Some(len) = highlight_reply_subjects[y] {
let index = e.index.0 * 4 + 1 + strings[y].len() - len;
let area = ((index, 2 * y), (width - 2, 2 * y));
@@ -267,7 +292,12 @@ impl ThreadView {
self.content = content;
}
- fn make_entry(&mut self, i: (usize, usize, usize), msg_idx: EnvelopeHash,