summaryrefslogtreecommitdiffstats
path: root/ui/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/components')
-rw-r--r--ui/src/components/contacts.rs2
-rw-r--r--ui/src/components/mail.rs4
-rw-r--r--ui/src/components/mail/compose.rs9
-rw-r--r--ui/src/components/mail/listing.rs4
-rw-r--r--ui/src/components/mail/listing/compact.rs58
-rw-r--r--ui/src/components/mail/listing/plain.rs9
-rw-r--r--ui/src/components/mail/listing/thread.rs6
-rw-r--r--ui/src/components/mail/view.rs31
-rw-r--r--ui/src/components/mail/view/envelope.rs6
-rw-r--r--ui/src/components/mail/view/html.rs2
-rw-r--r--ui/src/components/mail/view/thread.rs4
-rw-r--r--ui/src/components/utilities.rs2
-rw-r--r--ui/src/components/utilities/widgets.rs6
13 files changed, 66 insertions, 77 deletions
diff --git a/ui/src/components/contacts.rs b/ui/src/components/contacts.rs
index 3f844b85..e3fa8b84 100644
--- a/ui/src/components/contacts.rs
+++ b/ui/src/components/contacts.rs
@@ -139,7 +139,7 @@ impl Component for ContactManager {
match self.form.buttons_result() {
None => {}
Some(true) => {
- let mut fields = std::mem::replace(&mut self.form, FormWidget::default())
+ let fields = std::mem::replace(&mut self.form, FormWidget::default())
.collect()
.unwrap();
let fields: FnvHashMap<String, String> = fields
diff --git a/ui/src/components/mail.rs b/ui/src/components/mail.rs
index e706982c..4fdf4c93 100644
--- a/ui/src/components/mail.rs
+++ b/ui/src/components/mail.rs
@@ -27,9 +27,9 @@ use melib::backends::FolderHash;
use melib::thread::ThreadHash;
pub mod listing;
-pub use listing::*;
+pub use crate::listing::*;
pub mod view;
-pub use view::*;
+pub use crate::view::*;
mod compose;
pub use self::compose::*;
diff --git a/ui/src/components/mail/compose.rs b/ui/src/components/mail/compose.rs
index de73c790..ef12e292 100644
--- a/ui/src/components/mail/compose.rs
+++ b/ui/src/components/mail/compose.rs
@@ -129,7 +129,7 @@ impl Composer {
*/
pub fn edit(account_pos: usize, h: EnvelopeHash, context: &Context) -> Self {
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);
ret.draft = Draft::edit(envelope, op);
@@ -149,7 +149,7 @@ impl Composer {
let mut ret = Composer::default();
let p = &thread_nodes[&msg];
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();
ret.draft = Draft::new_reply(parent_message, parent_bytes.unwrap());
@@ -538,7 +538,7 @@ impl Component for Composer {
.spawn()
.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();
let draft = self.draft.clone().finalise().unwrap();
stdin
@@ -582,8 +582,7 @@ impl Component for Composer {
}
/* update Draft's headers based on form values */
self.update_draft();
- let mut f =
- create_temp_file(self.draft.to_string().unwrap().as_str().as_bytes(), None);
+ let f = create_temp_file(self.draft.to_string().unwrap().as_str().as_bytes(), None);
//let mut f = Box::new(std::fs::File::create(&dir).unwrap());
// TODO: check exit status
diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs
index 8c16ac82..a6510a04 100644
--- a/ui/src/components/mail/listing.rs
+++ b/ui/src/components/mail/listing.rs
@@ -39,7 +39,7 @@ struct AccountMenuEntry {
trait ListingTrait {
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)]
@@ -48,7 +48,7 @@ pub enum ListingComponent {
Threaded(ThreadListing),
Compact(CompactListing),
}
-use ListingComponent::*;
+use crate::ListingComponent::*;
impl ListingTrait for ListingComponent {
fn coordinates(&self) -> (usize, usize, Option<EnvelopeHash>) {
diff --git a/ui/src/components/mail/listing/compact.rs b/ui/src/components/mail/listing/compact.rs
index 858b64b9..f29e8ebf 100644
--- a/ui/src/components/mail/listing/compact.rs
+++ b/ui/src/components/mail/listing/compact.rs
@@ -20,7 +20,7 @@
*/
use super::*;
-use components::utilities::PageMovement;
+use crate::components::utilities::PageMovement;
use std::cmp;
use std::ops::{Deref, DerefMut};
@@ -242,7 +242,7 @@ impl MailboxView {
}
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!(
"name = {} {}",
@@ -292,7 +292,7 @@ impl MailboxView {
}
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!(
// "name = {} {}",
@@ -326,7 +326,7 @@ impl MailboxView {
for x in x..min_width.0 {
self.columns[0][(x, idx)].set_bg(bg_color);
}
- let (mut x, _) = write_string_to_grid(
+ let (x, _) = write_string_to_grid(
&strings.1,
&mut self.columns[1],
fg_color,
@@ -460,7 +460,7 @@ impl MailboxView {
let (upper_left, bottom_right) = area;
let grid = grid.unwrap();
- let (mut x, y) = upper_left;
+ let (mut x, _y) = upper_left;
for i in 0..self.columns.len() {
let (width, height) = self.columns[i].size();
if self.widths[i] == 0 {
@@ -861,32 +861,28 @@ impl Component for MailboxView {
return true;
}
Action::ToggleThreadSnooze => {
- {
- //FIXME NLL
- let account = &mut context.accounts[self.cursor_pos.0];
- let folder_hash = account[self.cursor_pos.1]
- .as_ref()
- .map(|m| m.folder.hash())
- .unwrap();
- let threads = account.collection.threads.entry(folder_hash).or_default();
- let thread_group = threads.thread_nodes()
- [&threads.root_set(self.cursor_pos.2)]
- .thread_group();
- let thread_group = threads.find(thread_group);
- /*let i = if let Some(i) = threads.thread_nodes[&thread_group].message() {
- i
- } else {
- let mut iter_ptr = threads.thread_nodes[&thread_group].children()[0];
- while threads.thread_nodes()[&iter_ptr].message().is_none() {
- iter_ptr = threads.thread_nodes()[&iter_ptr].children()[0];
- }
- threads.thread_nodes()[&iter_ptr].message().unwrap()
- };*/
- let root_node = threads.thread_nodes.entry(thread_group).or_default();
- let is_snoozed = root_node.snoozed();
- root_node.set_snoozed(!is_snoozed);
- //self.row_updates.push(i);
- }
+ let account = &mut context.accounts[self.cursor_pos.0];
+ let folder_hash = account[self.cursor_pos.1]
+ .as_ref()
+ .map(|m| m.folder.hash())
+ .unwrap();
+ let threads = account.collection.threads.entry(folder_hash).or_default();
+ let thread_group =
+ threads.thread_nodes()[&threads.root_set(self.cursor_pos.2)].thread_group();
+ let thread_group = threads.find(thread_group);
+ /*let i = if let Some(i) = threads.thread_nodes[&thread_group].message() {
+ i
+ } else {
+ let mut iter_ptr = threads.thread_nodes[&thread_group].children()[0];
+ while threads.thread_nodes()[&iter_ptr].message().is_none() {
+ iter_ptr = threads.thread_nodes()[&iter_ptr].children()[0];
+ }
+ threads.thread_nodes()[&iter_ptr].message().unwrap()
+ };*/
+ let root_node = threads.thread_nodes.entry(thread_group).or_default();
+ let is_snoozed = root_node.snoozed();
+ root_node.set_snoozed(!is_snoozed);
+ //self.row_updates.push(i);
self.refresh_mailbox(context);
return true;
}
diff --git a/ui/src/components/mail/listing/plain.rs b/ui/src/components/mail/listing/plain.rs
index e5758356..b39c546e 100644
--- a/ui/src/components/mail/listing/plain.rs
+++ b/ui/src/components/mail/listing/plain.rs
@@ -246,8 +246,7 @@ impl PlainListing {
1
};
// Populate `CellBuffer` with every entry.
- let mut idx = 0;
- for y in 0..=self.length {
+ for (idx, y) in (0..=self.length).enumerate() {
if idx >= self.length {
/* 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)));
@@ -280,7 +279,7 @@ impl PlainListing {
self.content[(x, idx)].set_bg(bg_color);
}
let mut _x = widths.0 + column_sep;
- let (mut x, _) = write_string_to_grid(
+ let (x, _) = write_string_to_grid(
&rows[idx].2,
&mut self.content,
fg_color,
@@ -317,8 +316,6 @@ impl PlainListing {
self.content[(x, y)].set_ch(' ');
self.content[(x, y)].set_bg(bg_color);
}
-
- idx += 1;
}
}
@@ -537,7 +534,7 @@ impl Component for PlainListing {
coordinates.1,
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(
grid,
diff --git a/ui/src/components/mail/listing/thread.rs b/ui/src/components/mail/listing/thread.rs
index a9929291..772361d6 100644
--- a/ui/src/components/mail/listing/thread.rs
+++ b/ui/src/components/mail/listing/thread.rs
@@ -20,7 +20,7 @@
*/
use super::*;
-use components::utilities::PageMovement;
+use crate::components::utilities::PageMovement;
const MAX_COLS: usize = 500;
@@ -475,7 +475,7 @@ impl Component for ThreadListing {
(envelope.hash(), envelope.is_seen())
};
if !is_seen {
- let op = account.operation(&hash);
+ let op = account.operation(hash);
let envelope: &mut Envelope =
account.get_env_mut(&self.locations[self.cursor_pos.2]);
envelope.set_seen(op).unwrap();
@@ -533,7 +533,7 @@ impl Component for ThreadListing {
if let Some(ref mut v) = self.view {
v.update(coordinates);
} else {
- self.view = Some(MailView::new(coordinates, None, None, context));
+ self.view = Some(MailView::new(coordinates, None, None));
}
self.view.as_mut().unwrap().draw(
diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs
index 5d44c0c1..30ec1f18 100644
--- a/ui/src/components/mail/view.rs
+++ b/ui/src/components/mail/view.rs
@@ -21,6 +21,7 @@
use super::*;
use linkify::{Link, LinkFinder};
+
use std::process::{Command, Stdio};
mod html;
@@ -86,7 +87,6 @@ impl MailView {
coordinates: (usize, usize, EnvelopeHash),
pager: Option<Pager>,
subview: Option<Box<Component>>,
- context: &mut Context,
) -> Self {
MailView {
coordinates,
@@ -168,9 +168,10 @@ impl MailView {
v.extend(html_filter.wait_with_output().unwrap().stdout);
} else {
context.replies.push_back(UIEvent::Notification(
- Some(format!(
+ Some(
"Failed to find any application to use as html filter"
- )),
+ .to_string(),
+ ),
String::new(),
));
return;
@@ -282,7 +283,7 @@ impl Component for MailView {
let y: usize = {
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
* arrive */
return;
@@ -292,11 +293,7 @@ impl Component for MailView {
(envelope.hash(), envelope.is_seen())
};
if !is_seen {
- let folder_hash = {
- let mailbox = &mut account[self.coordinates.1].as_mut().unwrap();
- mailbox.folder.hash()
- };
- let op = account.operation(&hash);
+ let op = account.operation(hash);
let envelope: &mut Envelope = &mut account.get_env_mut(&self.coordinates.2);
envelope.set_seen(op).unwrap();
}
@@ -392,7 +389,7 @@ impl Component for MailView {
envelope
.references()
.iter()
- .map(|r| r.to_string())
+ .map(std::string::ToString::to_string)
.collect::<Vec<String>>()
.join(", ")
),
@@ -421,7 +418,7 @@ impl Component for MailView {
let body = {
let account = &mut context.accounts[self.coordinates.0];
let envelope: &Envelope = &account.get_env(&self.coordinates.2);
- let op = account.operation(&envelope.hash());
+ let op = account.operation(envelope.hash());
envelope.body(op)
};
match self.mode {
@@ -446,7 +443,7 @@ impl Component for MailView {
let text = {
let account = &mut context.accounts[self.coordinates.0];
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()
.map(|v| String::from_utf8_lossy(v).into_owned())
.unwrap_or_else(|e| e.to_string())
@@ -618,7 +615,7 @@ impl Component for MailView {
{
let account = &mut context.accounts[self.coordinates.0];
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) {
match u.content_type() {
ContentType::MessageRfc822 => {
@@ -657,7 +654,7 @@ impl Component for MailView {
let attachment_type = u.mime_type();
let binary = query_default_app(&attachment_type);
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)
.arg(p.path())
.stdin(Stdio::piped())
@@ -714,8 +711,8 @@ impl Component for MailView {
let account = &mut context.accounts[self.coordinates.0];
let envelope: &Envelope = &account.get_env(&self.coordinates.2);
let finder = LinkFinder::new();
- let op = account.operation(&envelope.hash());
- let mut t = envelope.body(op).text().to_string();
+ let op = account.operation(envelope.hash());
+ let t = envelope.body(op).text().to_string();
let links: Vec<Link> = finder.links(&t).collect();
if let Some(u) = links.get(lidx) {
u.as_str().to_string()
@@ -742,7 +739,7 @@ impl Component for MailView {
}
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;
}
_ => {
diff --git a/ui/src/components/mail/view/envelope.rs b/ui/src/components/mail/view/envelope.rs
index 62467196..9893ca4a 100644
--- a/ui/src/components/mail/view/envelope.rs
+++ b/ui/src/components/mail/view/envelope.rs
@@ -336,7 +336,7 @@ impl Component for EnvelopeView {
let cursor_pos = if self.mode.is_attachment() {
Some(0)
} else {
- self.pager.as_mut().map(|p| p.cursor_pos())
+ self.pager.as_ref().map(Pager::cursor_pos)
};
self.pager = Some(Pager::from_string(
text,
@@ -439,7 +439,7 @@ impl Component for EnvelopeView {
let attachment_type = u.mime_type();
let binary = query_default_app(&attachment_type);
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)
.arg(p.path())
.stdin(Stdio::piped())
@@ -491,7 +491,7 @@ impl Component for EnvelopeView {
let url = {
let envelope: &Envelope = self.wrapper.envelope();
let finder = LinkFinder::new();
- let mut t = envelope
+ let t = envelope
.body_bytes(self.wrapper.buffer())
.text()
.to_string();
diff --git a/ui/src/components/mail/view/html.rs b/ui/src/components/mail/view/html.rs
index 0c89db9e..1b80c7ac 100644
--- a/ui/src/components/mail/view/html.rs
+++ b/ui/src/components/mail/view/html.rs
@@ -132,7 +132,7 @@ impl Component for HtmlView {
// scripts)
let binary = query_default_app("text/html");
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)
.arg(p.path())
.stdin(Stdio::piped())
diff --git a/ui/src/components/mail/view/thread.rs b/ui/src/components/mail/view/thread.rs
index 7b1fca8c..ed6936bb 100644
--- a/ui/src/components/mail/view/thread.rs
+++ b/ui/src/components/mail/view/thread.rs
@@ -20,7 +20,7 @@
*/
use super::*;
-use components::utilities::PageMovement;
+use crate::components::utilities::PageMovement;
use std::cmp;
const INDENTATION_COLORS: &'static [u8] = &[
@@ -916,7 +916,7 @@ impl Component for ThreadView {
.unwrap()
};
let envelope: &Envelope = &account.get_env(&i);
- let op = account.operation(&envelope.hash());
+ let op = account.operation(envelope.hash());
debug!(
"sending action edit for {}, {}",
envelope.message_id(),
diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs
index 7ea825af..10cb56dd 100644
--- a/ui/src/components/utilities.rs
+++ b/ui/src/components/utilities.rs
@@ -336,7 +336,7 @@ impl Pager {
.spawn()
.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
.write_all(text.as_bytes())
.expect("Failed to write to stdin");
diff --git a/ui/src/components/utilities/widgets.rs b/ui/src/components/utilities/widgets.rs
index 5721ea4a..a3ad1e18 100644
--- a/ui/src/components/utilities/widgets.rs
+++ b/ui/src/components/utilities/widgets.rs
@@ -32,7 +32,7 @@ impl Debug for Field {
}
}
-use Field::*;
+use crate::Field::*;
impl Default for Field {
fn default() -> Field {
@@ -749,14 +749,14 @@ impl ScrollBar {
return;
}
if self.show_arrows {
- height = height - 2;
+ height -= height;
}
clear_area(grid, area);
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_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 {
height - scrollbar_height
} else {