fix warnings and lints
parent
de81fd1a68
commit
4582bcd5ae
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod dbg {
|
pub mod dbg {
|
||||||
|
#[allow(clippy::redundant_closure)]
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! debug {
|
macro_rules! debug {
|
||||||
($val:literal) => {
|
($val:literal) => {
|
||||||
|
|
|
@ -821,6 +821,7 @@ mod tests {
|
||||||
let mut buffer: Vec<u8> = Vec::new();
|
let mut buffer: Vec<u8> = Vec::new();
|
||||||
//FIXME: add file
|
//FIXME: add file
|
||||||
return;
|
return;
|
||||||
|
/*
|
||||||
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() {
|
||||||
|
@ -834,6 +835,7 @@ mod tests {
|
||||||
.map(|v| std::str::from_utf8(v).unwrap())
|
.map(|v| std::str::from_utf8(v).unwrap())
|
||||||
.collect();
|
.collect();
|
||||||
println!("attachments {:?}", v);
|
println!("attachments {:?}", v);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn test_addresses() {
|
fn test_addresses() {
|
||||||
|
|
|
@ -9,7 +9,7 @@ xdg = "2.1.0" # >:c
|
||||||
serde = "1.0.71"
|
serde = "1.0.71"
|
||||||
serde_derive = "1.0.71"
|
serde_derive = "1.0.71"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
config = "0.6"
|
config = { path = "../../config-rs", version = "*" }
|
||||||
chan = "0.1.21"
|
chan = "0.1.21"
|
||||||
chan-signal = "0.3.1"
|
chan-signal = "0.3.1"
|
||||||
fnv = "1.0.3" # >:c
|
fnv = "1.0.3" # >:c
|
||||||
|
|
|
@ -104,9 +104,10 @@ impl Component for Listing {
|
||||||
let bottom_right = bottom_right!(area);
|
let bottom_right = bottom_right!(area);
|
||||||
let total_cols = get_x(bottom_right) - get_x(upper_left);
|
let total_cols = get_x(bottom_right) - get_x(upper_left);
|
||||||
|
|
||||||
let right_component_width = match self.menu_visibility {
|
let right_component_width = if self.menu_visibility {
|
||||||
true => (self.ratio * total_cols) / 100,
|
(self.ratio * total_cols) / 100
|
||||||
false => total_cols,
|
} else {
|
||||||
|
total_cols
|
||||||
};
|
};
|
||||||
let mid = get_x(bottom_right) - right_component_width;
|
let mid = get_x(bottom_right) - right_component_width;
|
||||||
if self.dirty && mid != get_x(upper_left) {
|
if self.dirty && mid != get_x(upper_left) {
|
||||||
|
@ -568,7 +569,7 @@ impl Listing {
|
||||||
(Color::Default, Color::Default)
|
(Color::Default, Color::Default)
|
||||||
};
|
};
|
||||||
|
|
||||||
let (x, _) = write_string_to_grid(
|
write_string_to_grid(
|
||||||
&s,
|
&s,
|
||||||
grid,
|
grid,
|
||||||
color_fg,
|
color_fg,
|
||||||
|
|
|
@ -92,7 +92,7 @@ column_str!(struct SubjectString(String));
|
||||||
|
|
||||||
impl fmt::Display for MailboxView {
|
impl fmt::Display for MailboxView {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "")
|
write!(f, "{}", MailboxView::DESCRIPTION)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,11 +237,9 @@ impl MailboxView {
|
||||||
self.order.insert(i, idx);
|
self.order.insert(i, idx);
|
||||||
}
|
}
|
||||||
let widths: (usize, usize, usize);
|
let widths: (usize, usize, usize);
|
||||||
let column_sep: usize;
|
let column_sep: usize = if MAX_COLS >= min_width.0 + min_width.1 + min_width.2 {
|
||||||
|
|
||||||
if MAX_COLS >= min_width.0 + min_width.1 + min_width.2 {
|
|
||||||
widths = min_width;
|
widths = min_width;
|
||||||
column_sep = 2;
|
2
|
||||||
} else {
|
} else {
|
||||||
let width = MAX_COLS - 3 - min_width.0;
|
let width = MAX_COLS - 3 - min_width.0;
|
||||||
widths = (
|
widths = (
|
||||||
|
@ -249,8 +247,8 @@ impl MailboxView {
|
||||||
cmp::min(min_width.1, width / 3),
|
cmp::min(min_width.1, width / 3),
|
||||||
cmp::min(min_width.2, width / 3),
|
cmp::min(min_width.2, width / 3),
|
||||||
);
|
);
|
||||||
column_sep = 1;
|
1
|
||||||
}
|
};
|
||||||
|
|
||||||
for ((idx, root_idx), strings) in threads.root_iter().enumerate().zip(rows) {
|
for ((idx, root_idx), strings) in threads.root_iter().enumerate().zip(rows) {
|
||||||
let thread_node = &threads.thread_nodes()[root_idx];
|
let thread_node = &threads.thread_nodes()[root_idx];
|
||||||
|
@ -738,8 +736,10 @@ impl ListingTrait for CompactListing {
|
||||||
(self.cursor, self.views[self.cursor].cursor_pos.1, None)
|
(self.cursor, self.views[self.cursor].cursor_pos.1, None)
|
||||||
}
|
}
|
||||||
fn set_coordinates(&mut self, coordinates: (usize, usize, Option<EnvelopeHash>)) {
|
fn set_coordinates(&mut self, coordinates: (usize, usize, Option<EnvelopeHash>)) {
|
||||||
self.views[self.cursor].new_cursor_pos = (coordinates.0, coordinates.1, 0);
|
self.views
|
||||||
self.views[self.cursor].unfocused = false;
|
.get_mut(self.cursor)
|
||||||
|
.map(|v| v.new_cursor_pos = (coordinates.0, coordinates.1, 0));
|
||||||
|
self.views.get_mut(self.cursor).map(|v| v.unfocused = false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,9 +184,7 @@ impl ThreadListing {
|
||||||
i,
|
i,
|
||||||
threads,
|
threads,
|
||||||
&indentations,
|
&indentations,
|
||||||
self.length,
|
|
||||||
has_sibling,
|
has_sibling,
|
||||||
// context.accounts[self.cursor_pos.0].backend.operation(envelope.hash())
|
|
||||||
),
|
),
|
||||||
&mut self.content,
|
&mut self.content,
|
||||||
fg_color,
|
fg_color,
|
||||||
|
@ -194,6 +192,7 @@ impl ThreadListing {
|
||||||
((0, idx), (MAX_COLS - 1, idx)),
|
((0, idx), (MAX_COLS - 1, idx)),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
for x in x..MAX_COLS {
|
for x in x..MAX_COLS {
|
||||||
self.content[(x, idx)].set_ch(' ');
|
self.content[(x, idx)].set_ch(' ');
|
||||||
self.content[(x, idx)].set_bg(bg_color);
|
self.content[(x, idx)].set_bg(bg_color);
|
||||||
|
@ -205,7 +204,7 @@ impl ThreadListing {
|
||||||
|
|
||||||
match iter.peek() {
|
match iter.peek() {
|
||||||
Some((x, _, _)) if *x > indentation => {
|
Some((x, _, _)) if *x > indentation => {
|
||||||
if debug!(has_sibling) {
|
if has_sibling {
|
||||||
indentations.push(true);
|
indentations.push(true);
|
||||||
} else {
|
} else {
|
||||||
indentations.push(false);
|
indentations.push(false);
|
||||||
|
@ -366,7 +365,6 @@ impl ThreadListing {
|
||||||
node_idx: usize,
|
node_idx: usize,
|
||||||
threads: &Threads,
|
threads: &Threads,
|
||||||
indentations: &[bool],
|
indentations: &[bool],
|
||||||
idx_width: usize,
|
|
||||||
has_sibling: bool,
|
has_sibling: bool,
|
||||||
//op: Box<BackendOp>,
|
//op: Box<BackendOp>,
|
||||||
) -> String {
|
) -> String {
|
||||||
|
|
|
@ -70,36 +70,31 @@ impl HtmlView {
|
||||||
));
|
));
|
||||||
display_text
|
display_text
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Ok(mut html_filter) = Command::new("w3m")
|
||||||
if let Ok(mut html_filter) = Command::new("w3m")
|
.args(&["-I", "utf-8", "-T", "text/html"])
|
||||||
.args(&["-I", "utf-8", "-T", "text/html"])
|
.stdin(Stdio::piped())
|
||||||
.stdin(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.spawn()
|
||||||
.spawn()
|
{
|
||||||
{
|
html_filter
|
||||||
html_filter
|
.stdin
|
||||||
.stdin
|
.as_mut()
|
||||||
.as_mut()
|
.unwrap()
|
||||||
.unwrap()
|
.write_all(&bytes)
|
||||||
.write_all(&bytes)
|
.expect("Failed to write to html filter stdin");
|
||||||
.expect("Failed to write to html filter stdin");
|
let mut display_text =
|
||||||
let mut display_text = String::from(
|
String::from("Text piped through `w3m`. Press `v` to open in web browser. \n\n");
|
||||||
"Text piped through `w3m`. Press `v` to open in web browser. \n\n",
|
display_text.push_str(&String::from_utf8_lossy(
|
||||||
);
|
&html_filter.wait_with_output().unwrap().stdout,
|
||||||
display_text.push_str(&String::from_utf8_lossy(
|
));
|
||||||
&html_filter.wait_with_output().unwrap().stdout,
|
|
||||||
));
|
|
||||||
|
|
||||||
display_text
|
display_text
|
||||||
} 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".to_string()),
|
||||||
"Failed to find any application to use as html filter"
|
String::new(),
|
||||||
)),
|
));
|
||||||
String::new(),
|
String::from_utf8_lossy(&bytes).to_string()
|
||||||
));
|
|
||||||
String::from_utf8_lossy(&bytes).to_string()
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
if body.count_attachments() > 1 {
|
if body.count_attachments() > 1 {
|
||||||
display_text =
|
display_text =
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::ops::Index;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct ThreadEntry {
|
struct ThreadEntry {
|
||||||
|
@ -299,7 +298,7 @@ impl ThreadView {
|
||||||
),
|
),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
if let Some(len) = highlight_reply_subjects[y] {
|
if let Some(_len) = highlight_reply_subjects[y] {
|
||||||
let index = e.index.0 * 4 + 1;
|
let index = e.index.0 * 4 + 1;
|
||||||
let area = ((index, 2 * y), (width - 2, 2 * y));
|
let area = ((index, 2 * y), (width - 2, 2 * y));
|
||||||
let fg_color = Color::Byte(33);
|
let fg_color = Color::Byte(33);
|
||||||
|
@ -395,12 +394,11 @@ impl ThreadView {
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|ref v| v.iter())
|
.flat_map(|ref v| v.iter())
|
||||||
.collect();
|
.collect();
|
||||||
if (rows >= visibles.len()) {
|
if rows >= visibles.len() {
|
||||||
upper_left = pos_dec(upper_left!(area), (1, 0));
|
upper_left = pos_dec(upper_left!(area), (1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut visible_entry_counter = 0;
|
for (visible_entry_counter, v) in visibles.iter().skip(top_idx).take(rows).enumerate() {
|
||||||
for v in visibles.iter().skip(top_idx).take(rows) {
|
|
||||||
if visible_entry_counter >= rows {
|
if visible_entry_counter >= rows {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -417,7 +415,6 @@ impl ThreadView {
|
||||||
(width - 1, 2 * idx + 1),
|
(width - 1, 2 * idx + 1),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
visible_entry_counter += 1;
|
|
||||||
}
|
}
|
||||||
/* If cursor position has changed, remove the highlight from the previous position and
|
/* If cursor position has changed, remove the highlight from the previous position and
|
||||||
* apply it in the new one. */
|
* apply it in the new one. */
|
||||||
|
@ -449,7 +446,7 @@ impl ThreadView {
|
||||||
);
|
);
|
||||||
|
|
||||||
self.highlight_line(grid, dest_area, src_area, idx);
|
self.highlight_line(grid, dest_area, src_area, idx);
|
||||||
if (rows < visibles.len()) {
|
if rows < visibles.len() {
|
||||||
ScrollBar::draw(
|
ScrollBar::draw(
|
||||||
grid,
|
grid,
|
||||||
(
|
(
|
||||||
|
@ -473,7 +470,7 @@ impl ThreadView {
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|ref v| v.iter())
|
.flat_map(|ref v| v.iter())
|
||||||
.collect();
|
.collect();
|
||||||
if (rows >= visibles.len()) {
|
if rows >= visibles.len() {
|
||||||
upper_left = pos_dec(upper_left!(area), (1, 0));
|
upper_left = pos_dec(upper_left!(area), (1, 0));
|
||||||
}
|
}
|
||||||
for &idx in &[old_cursor_pos, self.cursor_pos] {
|
for &idx in &[old_cursor_pos, self.cursor_pos] {
|
||||||
|
@ -501,7 +498,7 @@ impl ThreadView {
|
||||||
);
|
);
|
||||||
|
|
||||||
self.highlight_line(grid, dest_area, src_area, entry_idx);
|
self.highlight_line(grid, dest_area, src_area, entry_idx);
|
||||||
if (rows < visibles.len()) {
|
if rows < visibles.len() {
|
||||||
ScrollBar::draw(
|
ScrollBar::draw(
|
||||||
grid,
|
grid,
|
||||||
(
|
(
|
||||||
|
@ -534,45 +531,41 @@ impl ThreadView {
|
||||||
|
|
||||||
/* First draw the thread subject on the first row */
|
/* First draw the thread subject on the first row */
|
||||||
let y = if self.dirty {
|
let y = if self.dirty {
|
||||||
let y = {
|
let mailbox = &mut context.accounts[self.coordinates.0][self.coordinates.1]
|
||||||
let mailbox = &mut context.accounts[self.coordinates.0][self.coordinates.1]
|
.as_ref()
|
||||||
.as_ref()
|
.unwrap();
|
||||||
.unwrap();
|
let threads = &mailbox.collection.threads;
|
||||||
let threads = &mailbox.collection.threads;
|
let thread_node = &threads.thread_nodes()[threads.root_set(self.coordinates.2)];
|
||||||
let thread_node = &threads.thread_nodes()[threads.root_set(self.coordinates.2)];
|
let i = if let Some(i) = thread_node.message() {
|
||||||
let i = if let Some(i) = thread_node.message() {
|
i
|
||||||
i
|
} else {
|
||||||
} else {
|
threads.thread_nodes()[thread_node.children()[0]]
|
||||||
threads.thread_nodes()[thread_node.children()[0]]
|
.message()
|
||||||
.message()
|
.unwrap()
|
||||||
.unwrap()
|
|
||||||
};
|
|
||||||
let envelope: &Envelope = &mailbox.collection[&i];
|
|
||||||
|
|
||||||
let (x, y) = write_string_to_grid(
|
|
||||||
&envelope.subject(),
|
|
||||||
grid,
|
|
||||||
Color::Byte(33),
|
|
||||||
Color::Default,
|
|
||||||
area,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
for x in x..=get_x(bottom_right) {
|
|
||||||
grid[(x, y)].set_ch(' ');
|
|
||||||
grid[(x, y)].set_bg(Color::Default);
|
|
||||||
grid[(x, y)].set_fg(Color::Default);
|
|
||||||
}
|
|
||||||
context
|
|
||||||
.dirty_areas
|
|
||||||
.push_back((upper_left, set_y(bottom_right, y + 1)));
|
|
||||||
context
|
|
||||||
.dirty_areas
|
|
||||||
.push_back(((mid, y + 1), set_x(bottom_right, mid)));
|
|
||||||
clear_area(grid, ((mid, y + 1), set_x(bottom_right, mid)));
|
|
||||||
y + 2
|
|
||||||
};
|
};
|
||||||
//clear_area(grid, (set_y(upper_left, y), set_x(bottom_right, mid)));
|
let envelope: &Envelope = &mailbox.collection[&i];
|
||||||
y
|
|
||||||
|
let (x, y) = write_string_to_grid(
|
||||||
|
&envelope.subject(),
|
||||||
|
grid,
|
||||||
|
Color::Byte(33),
|
||||||
|
Color::Default,
|
||||||
|
area,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
for x in x..=get_x(bottom_right) {
|
||||||
|
grid[(x, y)].set_ch(' ');
|
||||||
|
grid[(x, y)].set_bg(Color::Default);
|
||||||
|
grid[(x, y)].set_fg(Color::Default);
|
||||||
|
}
|
||||||
|
context
|
||||||
|
.dirty_areas
|
||||||
|
.push_back((upper_left, set_y(bottom_right, y + 1)));
|
||||||
|
context
|
||||||
|
.dirty_areas
|
||||||
|
.push_back(((mid, y + 1), set_x(bottom_right, mid)));
|
||||||
|
clear_area(grid, ((mid, y + 1), set_x(bottom_right, mid)));
|
||||||
|
y + 2
|
||||||
} else {
|
} else {
|
||||||
get_y(upper_left) + 2
|
get_y(upper_left) + 2
|
||||||
};
|
};
|
||||||
|
@ -716,9 +709,6 @@ impl ThreadView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visible_entries(&self) -> Vec<Vec<usize>> {
|
|
||||||
self.visible_entries.clone()
|
|
||||||
}
|
|
||||||
fn recalc_visible_entries(&mut self) {
|
fn recalc_visible_entries(&mut self) {
|
||||||
if self
|
if self
|
||||||
.entries
|
.entries
|
||||||
|
|
|
@ -45,7 +45,7 @@ impl Component for XDGNotifications {
|
||||||
notify_Notification::new()
|
notify_Notification::new()
|
||||||
.appname("meli")
|
.appname("meli")
|
||||||
.icon("mail-message-new")
|
.icon("mail-message-new")
|
||||||
.summary(title.as_ref().map(|v| v.as_str()).unwrap_or("Event"))
|
.summary(title.as_ref().map(String::as_str).unwrap_or("Event"))
|
||||||
.body(&escape_str(body))
|
.body(&escape_str(body))
|
||||||
.icon("dialog-information")
|
.icon("dialog-information")
|
||||||
.show()
|
.show()
|
||||||
|
@ -124,7 +124,7 @@ impl Component for NotificationFilter {
|
||||||
if let UIEvent::Notification(ref title, ref body) = event {
|
if let UIEvent::Notification(ref title, ref body) = event {
|
||||||
if let Some(ref bin) = context.runtime_settings.notifications.script {
|
if let Some(ref bin) = context.runtime_settings.notifications.script {
|
||||||
if let Err(v) = Command::new(bin)
|
if let Err(v) = Command::new(bin)
|
||||||
.arg(title.as_ref().map(|v| v.as_str()).unwrap_or("Event"))
|
.arg(title.as_ref().map(String::as_str).unwrap_or("Event"))
|
||||||
.arg(body)
|
.arg(body)
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
|
|
|
@ -187,7 +187,7 @@ impl Component for VSplit {
|
||||||
if get_y(upper_left) > 1 {
|
if get_y(upper_left) > 1 {
|
||||||
let c = grid
|
let c = grid
|
||||||
.get(mid, get_y(upper_left) - 1)
|
.get(mid, get_y(upper_left) - 1)
|
||||||
.map(|a| a.ch())
|
.map(Cell::ch)
|
||||||
.unwrap_or_else(|| ' ');
|
.unwrap_or_else(|| ' ');
|
||||||
if let HORZ_BOUNDARY = c {
|
if let HORZ_BOUNDARY = c {
|
||||||
grid[(mid, get_y(upper_left) - 1)].set_ch(LIGHT_DOWN_AND_HORIZONTAL);
|
grid[(mid, get_y(upper_left) - 1)].set_ch(LIGHT_DOWN_AND_HORIZONTAL);
|
||||||
|
@ -203,7 +203,7 @@ impl Component for VSplit {
|
||||||
if get_y(bottom_right) > 1 {
|
if get_y(bottom_right) > 1 {
|
||||||
let c = grid
|
let c = grid
|
||||||
.get(mid, get_y(bottom_right) - 1)
|
.get(mid, get_y(bottom_right) - 1)
|
||||||
.map(|a| a.ch())
|
.map(Cell::ch)
|
||||||
.unwrap_or_else(|| ' ');
|
.unwrap_or_else(|| ' ');
|
||||||
if let HORZ_BOUNDARY = c {
|
if let HORZ_BOUNDARY = c {
|
||||||
grid[(mid, get_y(bottom_right) + 1)].set_ch(LIGHT_UP_AND_HORIZONTAL);
|
grid[(mid, get_y(bottom_right) + 1)].set_ch(LIGHT_UP_AND_HORIZONTAL);
|
||||||
|
@ -475,7 +475,7 @@ impl Component for Pager {
|
||||||
if self.cursor_pos + height >= self.height {
|
if self.cursor_pos + height >= self.height {
|
||||||
self.cursor_pos = self.height.saturating_sub(height);
|
self.cursor_pos = self.height.saturating_sub(height);
|
||||||
};
|
};
|
||||||
let pos = copy_area_with_break(
|
copy_area_with_break(
|
||||||
grid,
|
grid,
|
||||||
&self.content,
|
&self.content,
|
||||||
area,
|
area,
|
||||||
|
@ -872,7 +872,6 @@ impl Tabbed {
|
||||||
}
|
}
|
||||||
fn draw_tabs(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
fn draw_tabs(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||||
let upper_left = upper_left!(area);
|
let upper_left = upper_left!(area);
|
||||||
let bottom_right = bottom_right!(area);
|
|
||||||
|
|
||||||
if self.children.is_empty() {
|
if self.children.is_empty() {
|
||||||
clear_area(grid, area);
|
clear_area(grid, area);
|
||||||
|
|
|
@ -645,7 +645,7 @@ impl AutoComplete {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut content = CellBuffer::new(
|
let mut content = CellBuffer::new(
|
||||||
entries.iter().map(|e| e.len()).max().unwrap_or(0) + 1,
|
entries.iter().map(String::len).max().unwrap_or(0) + 1,
|
||||||
entries.len(),
|
entries.len(),
|
||||||
Cell::with_style(Color::Byte(23), Color::Byte(7), Attr::Default),
|
Cell::with_style(Color::Byte(23), Color::Byte(7), Attr::Default),
|
||||||
);
|
);
|
||||||
|
|
|
@ -107,7 +107,7 @@ impl Default for FolderConf {
|
||||||
|
|
||||||
impl FolderConf {
|
impl FolderConf {
|
||||||
pub fn rename(&self) -> Option<&str> {
|
pub fn rename(&self) -> Option<&str> {
|
||||||
self.rename.as_ref().map(|v| v.as_str())
|
self.rename.as_ref().map(String::as_str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ impl From<FileAccount> for AccountConf {
|
||||||
display_name,
|
display_name,
|
||||||
};
|
};
|
||||||
|
|
||||||
let folder_confs = x.folders.clone().unwrap_or_else(|| Default::default());
|
let folder_confs = x.folders.clone().unwrap_or_else(Default::default);
|
||||||
|
|
||||||
AccountConf {
|
AccountConf {
|
||||||
account: acc,
|
account: acc,
|
||||||
|
@ -173,7 +173,7 @@ impl FileAccount {
|
||||||
self.sent_folder.as_str()
|
self.sent_folder.as_str()
|
||||||
}
|
}
|
||||||
pub fn html_filter(&self) -> Option<&str> {
|
pub fn html_filter(&self) -> Option<&str> {
|
||||||
self.html_filter.as_ref().map(|f| f.as_str())
|
self.html_filter.as_ref().map(String::as_str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ impl FileSettings {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
/* No point in returning without a config file. */
|
/* No point in returning without a config file. */
|
||||||
match s.deserialize() {
|
match s.try_into() {
|
||||||
Ok(v) => Ok(v),
|
Ok(v) => Ok(v),
|
||||||
Err(e) => Err(MeliError::new(e.to_string())),
|
Err(e) => Err(MeliError::new(e.to_string())),
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,21 +108,20 @@ impl<'a> Iterator for MailboxIterator<'a> {
|
||||||
if self.pos == self.folders.len() {
|
if self.pos == self.folders.len() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
for fh in self.folders_order[self.pos..].iter() {
|
let fh = &self.folders_order[self.pos];
|
||||||
if self.pos == self.folders.len() {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.pos += 1;
|
if self.pos == self.folders.len() {
|
||||||
if self.folders[&fh].is_none() {
|
return None;
|
||||||
return Some(None);
|
|
||||||
}
|
|
||||||
if let Some(Err(_)) = self.folders[&fh] {
|
|
||||||
return Some(None);
|
|
||||||
}
|
|
||||||
return Some(Some(self.folders[&fh].as_ref().unwrap().as_ref().unwrap()));
|
|
||||||
}
|
}
|
||||||
return None;
|
|
||||||
|
self.pos += 1;
|
||||||
|
if self.folders[&fh].is_none() {
|
||||||
|
return Some(None);
|
||||||
|
}
|
||||||
|
if let Some(Err(_)) = self.folders[&fh] {
|
||||||
|
return Some(None);
|
||||||
|
}
|
||||||
|
return Some(Some(self.folders[&fh].as_ref().unwrap().as_ref().unwrap()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,8 +154,8 @@ impl Account {
|
||||||
.or_default();
|
.or_default();
|
||||||
if (f.name().eq_ignore_ascii_case("junk")
|
if (f.name().eq_ignore_ascii_case("junk")
|
||||||
|| f.name().eq_ignore_ascii_case("spam")
|
|| f.name().eq_ignore_ascii_case("spam")
|
||||||
|| f.name().eq_ignore_ascii_case("trash")
|
|| f.name().eq_ignore_ascii_case("sent")
|
||||||
|| f.name().eq_ignore_ascii_case("sent"))
|
|| f.name().eq_ignore_ascii_case("trash"))
|
||||||
&& entry.ignore.is_unset()
|
&& entry.ignore.is_unset()
|
||||||
{
|
{
|
||||||
entry.ignore = ToggleFlag::InternalVal(true);
|
entry.ignore = ToggleFlag::InternalVal(true);
|
||||||
|
@ -181,10 +180,6 @@ impl Account {
|
||||||
|
|
||||||
tree.push(rec(*h, &ref_folders));
|
tree.push(rec(*h, &ref_folders));
|
||||||
for &c in f.children() {
|
for &c in f.children() {
|
||||||
let k = FolderNode {
|
|
||||||
hash: c,
|
|
||||||
kids: Vec::new(),
|
|
||||||
};
|
|
||||||
stack.push(c);
|
stack.push(c);
|
||||||
}
|
}
|
||||||
while let Some(next) = stack.pop() {
|
while let Some(next) = stack.pop() {
|
||||||
|
@ -206,10 +201,10 @@ impl Account {
|
||||||
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(|r| Some(r)));
|
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(|r| Some(r)));
|
stack.extend(next.kids.iter().rev().map(Some));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -455,7 +450,7 @@ impl Account {
|
||||||
pub fn save(&self, bytes: &[u8], folder: &str) -> Result<()> {
|
pub fn save(&self, bytes: &[u8], folder: &str) -> Result<()> {
|
||||||
self.backend.save(bytes, folder)
|
self.backend.save(bytes, folder)
|
||||||
}
|
}
|
||||||
pub fn iter_mailboxes<'a>(&'a self) -> MailboxIterator<'a> {
|
pub fn iter_mailboxes(&self) -> MailboxIterator {
|
||||||
MailboxIterator {
|
MailboxIterator {
|
||||||
folders_order: &self.folders_order,
|
folders_order: &self.folders_order,
|
||||||
folders: &self.folders,
|
folders: &self.folders,
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
Define a (x, y) point in the terminal display as a holder of a character, foreground/background
|
Define a (x, y) point in the terminal display as a holder of a character, foreground/background
|
||||||
colors and attributes.
|
colors and attributes.
|
||||||
*/
|
*/
|
||||||
use super::grapheme_clusters::*;
|
|
||||||
use super::position::*;
|
use super::position::*;
|
||||||
use std::convert::From;
|
use std::convert::From;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
|
@ -72,22 +72,22 @@ impl<'s> Iterator for WordBreakIter<'s> {
|
||||||
let next_idx = graphemes[next_idx].0;
|
let next_idx = graphemes[next_idx].0;
|
||||||
let ret = &self.input[..next_idx];
|
let ret = &self.input[..next_idx];
|
||||||
self.input = &self.input[next_idx..];
|
self.input = &self.input[next_idx..];
|
||||||
return Some(ret);
|
Some(ret)
|
||||||
} else {
|
} else {
|
||||||
let ret = &self.input[..self.width];
|
let ret = &self.input[..self.width];
|
||||||
self.input = &self.input[self.width..];
|
self.input = &self.input[self.width..];
|
||||||
return Some(ret);
|
Some(ret)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* graphemes.len() < width */
|
/* graphemes.len() < width */
|
||||||
let ret = self.input;
|
let ret = self.input;
|
||||||
self.input = &self.input[0..0];
|
self.input = &self.input[0..0];
|
||||||
return Some(ret);
|
Some(ret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn word_break_string(mut s: &str, width: usize) -> Vec<&str> {
|
pub fn word_break_string(s: &str, width: usize) -> Vec<&str> {
|
||||||
let iter = WordBreakIter { input: s, width };
|
let iter = WordBreakIter { input: s, width };
|
||||||
iter.collect()
|
iter.collect()
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ use termion::event::Event as TermionEvent;
|
||||||
use termion::event::Key as TermionKey;
|
use termion::event::Key as TermionKey;
|
||||||
use termion::input::TermRead;
|
use termion::input::TermRead;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||||
pub enum Key {
|
pub enum Key {
|
||||||
/// Backspace.
|
/// Backspace.
|
||||||
Backspace,
|
Backspace,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use chan;
|
use chan;
|
||||||
use melib::async_workers::Work;
|
use melib::async_workers::Work;
|
||||||
use std;
|
use std;
|
||||||
use std::mem;
|
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
const MAX_WORKER: usize = 4;
|
const MAX_WORKER: usize = 4;
|
||||||
|
|
Loading…
Reference in New Issue