diff --git a/.gdbinit b/.gdbinit
new file mode 100644
index 000000000..dbc6aca42
--- /dev/null
+++ b/.gdbinit
@@ -0,0 +1,2 @@
+break rust_panic
+break core::option::expect_failed::h4927e1fef06c4878
diff --git a/src/bin.rs b/src/bin.rs
index 96299f8f7..c2e8c578b 100644
--- a/src/bin.rs
+++ b/src/bin.rs
@@ -18,6 +18,12 @@
* You should have received a copy of the GNU General Public License
* along with meli. If not, see .
*/
+
+/*! This crate contains the frontend stuff of the application. The application entry way on `src/bin.rs` creates an event loop and passes input to the `ui` module.
+
+The mail handling stuff is done in the `melib` crate which includes all backend needs. The split is done to theoretically be able to create different frontends with the same innards.
+ */
+
extern crate melib;
#[macro_use]
extern crate nom;
diff --git a/src/ui/cells.rs b/src/ui/cells.rs
index 0e7670c43..04e987c09 100644
--- a/src/ui/cells.rs
+++ b/src/ui/cells.rs
@@ -1,7 +1,14 @@
+/*!
+ Define a (x, y) point in the terminal display as a holder of a character, foreground/background
+ colors and attributes.
+ */
use std::ops::{Index, IndexMut, Deref, DerefMut};
use super::position::*;
use termion::color::AnsiValue;
+
+/// Types and implementations taken from rustty for convenience.
+
pub trait CellAccessor: HasSize {
fn cellvec(&self) -> &Vec;
fn cellvec_mut(&mut self) -> &mut Vec;
@@ -409,10 +416,10 @@ impl Color {
pub fn as_termion(&self) -> AnsiValue {
match *self {
b @ Color::Black | b @ Color::Red | b @ Color::Green | b @ Color::Yellow | b @ Color::Blue | b @ Color::Magenta | b @ Color::Cyan | b @ Color::White | b @ Color::Default =>
- {
+ {
AnsiValue(b.as_byte())
},
- Color::Byte(b) => {
+ Color::Byte(b) => {
AnsiValue(b as u8)
},
}
diff --git a/src/ui/components/mail.rs b/src/ui/components/mail.rs
index 1843c6668..c32772024 100644
--- a/src/ui/components/mail.rs
+++ b/src/ui/components/mail.rs
@@ -1,3 +1,5 @@
+/*! Entities that handle Mail specific functions.
+ */
use ui::components::*;
use ui::cells::*;
@@ -90,10 +92,10 @@ impl MailListing {
match iter.peek() {
Some(&(_, x))
if mailbox.get_thread(*x).get_indentation() == indentation =>
- {
- indentations.pop();
- indentations.push(true);
- }
+ {
+ indentations.pop();
+ indentations.push(true);
+ }
_ => {
indentations.pop();
indentations.push(false);
@@ -115,8 +117,8 @@ impl MailListing {
Color::Byte(236)
} else {
Color::Default
- }
- let x = write_string_to_grid(&MailListing::make_thread_entry(envelope, idx, indentation, container, idx == self.cursor_pos.2, &indentations),
+ };
+ let x = write_string_to_grid(&MailListing::make_thread_entry(envelope, idx, indentation, container, &indentations),
&mut content,
fg_color,
bg_color,
@@ -129,23 +131,23 @@ impl MailListing {
match iter.peek() {
Some(&(_, x))
if mailbox.get_thread(*x).get_indentation() > indentation =>
- {
- indentations.push(false);
- }
+ {
+ indentations.push(false);
+ }
Some(&(_, x))
if mailbox.get_thread(*x).get_indentation() < indentation =>
- {
- for _ in 0..(indentation - mailbox.get_thread(*x).get_indentation()) {
- indentations.pop();
+ {
+ for _ in 0..(indentation - mailbox.get_thread(*x).get_indentation()) {
+ indentations.pop();
+ }
}
- }
_ => {}
}
}
} else {
- // Populate `CellBuffer` with every entry.
- // TODO: Lazy load?
+ // Populate `CellBuffer` with every entry.
+ // TODO: Lazy load?
let mut idx = 0;
for y in 0..=self.length {
if idx >= self.length {
@@ -254,6 +256,40 @@ impl MailListing {
context.dirty_areas.push_back(area);
}
+ /// Create a pager for the `Envelope` currently under the cursor.
+ fn draw_header_view(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
+ {
+ let threaded = context.accounts[self.cursor_pos.0].settings.threaded;
+ let mailbox = &mut context.accounts[self.cursor_pos.0][self.cursor_pos.1].as_ref().unwrap().as_ref().unwrap();
+ let envelope: &Envelope = if threaded {
+ let i = mailbox.get_threaded_mail(self.cursor_pos.2);
+ &mailbox.collection[i]
+ } else {
+ &mailbox.collection[self.cursor_pos.2]
+ };
+
+ let pager_filter = context.settings.pager.filter.clone();
+ self.pager = Some(Pager::new(&envelope, pager_filter));
+ }
+ self.pager.as_mut().map(|p| p.draw(grid, area, context));
+ }
+ /// Create a pager for the `Envelope` currently under the cursor.
+ fn draw_attachment_view(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
+ {
+ let threaded = context.accounts[self.cursor_pos.0].settings.threaded;
+ let mailbox = &mut context.accounts[self.cursor_pos.0][self.cursor_pos.1].as_ref().unwrap().as_ref().unwrap();
+ let envelope: &Envelope = if threaded {
+ let i = mailbox.get_threaded_mail(self.cursor_pos.2);
+ &mailbox.collection[i]
+ } else {
+ &mailbox.collection[self.cursor_pos.2]
+ };
+
+ let pager_filter = context.settings.pager.filter.clone();
+ self.pager = Some(Pager::new(&envelope, pager_filter));
+ }
+ self.pager.as_mut().map(|p| p.draw(grid, area, context));
+ }
/// Create a pager for the `Envelope` currently under the cursor.
fn draw_mail_view(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
{
@@ -272,28 +308,12 @@ impl MailListing {
self.pager.as_mut().map(|p| p.draw(grid, area, context));
}
fn make_thread_entry(envelope: &Envelope, idx: usize, indent: usize,
- container: &Container, highlight: bool, indentations: &Vec) -> String {
+ container: &Container, indentations: &Vec) -> String {
let has_sibling = container.has_sibling();
let has_parent = container.has_parent();
let show_subject = container.get_show_subject();
- let fg_color = if !envelope.is_seen() {
- Color::Byte(0)
- } else {
- Color::Default
- };
- let bg_color = if highlight {
- if !envelope.is_seen() {
- Color::Byte(252)
- } else if idx % 2 == 0 {
- Color::Byte(236)
- } else {
- Color::Default
- }
- } else {
- Color::Byte(246)
- };
- let mut s = format!("{} {} ", idx, &envelope.get_datetime().format("%Y-%m-%d %H:%M:%S").to_string()); // {} {:.85}",idx,),e.get_subject())
+ let mut s = format!("{} {} ", idx, &envelope.get_datetime().format("%Y-%m-%d %H:%M:%S").to_string());
for i in 0..indent {
if indentations.len() > i && indentations[i]
{
@@ -398,50 +418,50 @@ impl Component for MailListing {
};
let x = write_string_to_grid(&format!("Date: {}", envelope.get_date_as_str()),
- grid,
- Color::Byte(33),
- Color::Default,
- (set_y(upper_left, mid+1), set_y(bottom_right, mid+1)));
+ grid,
+ Color::Byte(33),
+ Color::Default,
+ (set_y(upper_left, mid+1), set_y(bottom_right, mid+1)));
for x in x..=get_x(bottom_right) {
grid[(x, mid+1)].set_ch(' ');
grid[(x, mid+1)].set_bg(Color::Default);
grid[(x, mid+1)].set_fg(Color::Default);
}
let x = write_string_to_grid(&format!("From: {}", envelope.get_from()),
- grid,
- Color::Byte(33),
- Color::Default,
- (set_y(upper_left, mid+2), set_y(bottom_right, mid+2)));
+ grid,
+ Color::Byte(33),
+ Color::Default,
+ (set_y(upper_left, mid+2), set_y(bottom_right, mid+2)));
for x in x..=get_x(bottom_right) {
grid[(x, mid+2)].set_ch(' ');
grid[(x, mid+2)].set_bg(Color::Default);
grid[(x, mid+2)].set_fg(Color::Default);
}
let x = write_string_to_grid(&format!("To: {}", envelope.get_to()),
- grid,
- Color::Byte(33),
- Color::Default,
- (set_y(upper_left, mid+3), set_y(bottom_right, mid+3)));
+ grid,
+ Color::Byte(33),
+ Color::Default,
+ (set_y(upper_left, mid+3), set_y(bottom_right, mid+3)));
for x in x..=get_x(bottom_right) {
grid[(x, mid+3)].set_ch(' ');
grid[(x, mid+3)].set_bg(Color::Default);
grid[(x, mid+3)].set_fg(Color::Default);
}
let x = write_string_to_grid(&format!("Subject: {}", envelope.get_subject()),
- grid,
- Color::Byte(33),
- Color::Default,
- (set_y(upper_left, mid+4), set_y(bottom_right, mid+4)));
+ grid,
+ Color::Byte(33),
+ Color::Default,
+ (set_y(upper_left, mid+4), set_y(bottom_right, mid+4)));
for x in x..=get_x(bottom_right) {
grid[(x, mid+4)].set_ch(' ');
grid[(x, mid+4)].set_bg(Color::Default);
grid[(x, mid+4)].set_fg(Color::Default);
}
let x = write_string_to_grid(&format!("Message-ID: {}", envelope.get_message_id_raw()),
- grid,
- Color::Byte(33),
- Color::Default,
- (set_y(upper_left, mid+5), set_y(bottom_right, mid+5)));
+ grid,
+ Color::Byte(33),
+ Color::Default,
+ (set_y(upper_left, mid+5), set_y(bottom_right, mid+5)));
for x in x..=get_x(bottom_right) {
grid[(x, mid+5)].set_ch(' ');
grid[(x, mid+5)].set_bg(Color::Default);
@@ -588,7 +608,7 @@ impl AccountMenu {
let highlight = self.cursor.map(|(x,_)| x == a.index).unwrap_or(false);
-
+
let mut parents: Vec | |