diff --git a/src/components/mail/listing/compact.rs b/src/components/mail/listing/compact.rs index b1c80990..21fb30ed 100644 --- a/src/components/mail/listing/compact.rs +++ b/src/components/mail/listing/compact.rs @@ -118,6 +118,12 @@ macro_rules! row_attr { }}; } +macro_rules! emoji_text_presentation_selector { + () => { + "\u{FE0E}" + }; +} + /// A list of all mail (`Envelope`s) in a `Mailbox`. On `\n` it opens the `Envelope` content in a /// `ThreadView`. #[derive(Debug)] @@ -932,30 +938,66 @@ impl CompactListing { } let mut subject = e.subject().to_string(); subject.truncate_at_boundary(150); - if thread.len() > 1 { - EntryStrings { - date: DateString(ConversationsListing::format_date(context, thread.date())), - subject: SubjectString(format!("{} ({})", subject, thread.len(),)), - flag: FlagString(format!( - "{}{}", - if thread.has_attachments() { "📎" } else { "" }, - if thread.snoozed() { "💤" } else { "" } - )), - from: FromString(address_list!((e.from()) as comma_sep_list)), - tags: TagString(tags, colors), - } - } else { - EntryStrings { - date: DateString(ConversationsListing::format_date(context, thread.date())), - subject: SubjectString(subject), - flag: FlagString(format!( - "{}{}", - if thread.has_attachments() { "📎" } else { "" }, - if thread.snoozed() { "💤" } else { "" } - )), - from: FromString(address_list!((e.from()) as comma_sep_list)), - tags: TagString(tags, colors), - } + EntryStrings { + date: DateString(ConversationsListing::format_date(context, thread.date())), + subject: if thread.len() > 1 { + SubjectString(format!("{} ({})", subject, thread.len(),)) + } else { + SubjectString(subject) + }, + flag: FlagString(format!( + "{}{}{}{}", + if thread.has_attachments() { + mailbox_settings!( + context[self.cursor_pos.0][&self.cursor_pos.1] + .listing + .attachment_flag + ) + .as_ref() + .map(|s| s.as_str()) + .unwrap_or(concat!("📎", emoji_text_presentation_selector!())) + } else { + "" + }, + if thread.snoozed() { + mailbox_settings!( + context[self.cursor_pos.0][&self.cursor_pos.1] + .listing + .thread_snoozed_flag + ) + .as_ref() + .map(|s| s.as_str()) + .unwrap_or(concat!("💤", emoji_text_presentation_selector!())) + } else { + "" + }, + if thread.unseen() > 0 { + mailbox_settings!( + context[self.cursor_pos.0][&self.cursor_pos.1] + .listing + .unseen_flag + ) + .as_ref() + .map(|s| s.as_str()) + .unwrap_or("●") + } else { + "" + }, + if self.selection.get(&hash).cloned().unwrap_or(false) { + mailbox_settings!( + context[self.cursor_pos.0][&self.cursor_pos.1] + .listing + .selected_flag + ) + .as_ref() + .map(|s| s.as_str()) + .unwrap_or(concat!("☑️", emoji_text_presentation_selector!())) + } else { + "" + }, + )), + from: FromString(address_list!((e.from()) as comma_sep_list)), + tags: TagString(tags, colors), } } diff --git a/src/conf/listing.rs b/src/conf/listing.rs index a971ece9..37c63e01 100644 --- a/src/conf/listing.rs +++ b/src/conf/listing.rs @@ -99,6 +99,26 @@ pub struct ListingSettings { ///Default: ' ' #[serde(default = "default_divider")] pub sidebar_divider: char, + + /// Flag to show if thread entry contains unseen mail. + /// Default: "●" + #[serde(default)] + pub unseen_flag: Option, + + /// Flag to show if thread has been snoozed. + /// Default: "💤" + #[serde(default)] + pub thread_snoozed_flag: Option, + + /// Flag to show if thread entry has been selected. + /// Default: "☑️" + #[serde(default)] + pub selected_flag: Option, + + /// Flag to show if thread entry contains attachments. + /// Default: "📎" + #[serde(default)] + pub attachment_flag: Option, } const fn default_divider() -> char { @@ -119,6 +139,10 @@ impl Default for ListingSettings { sidebar_mailbox_tree_has_sibling_leaf: None, sidebar_mailbox_tree_no_sibling_leaf: None, sidebar_divider: default_divider(), + unseen_flag: None, + thread_snoozed_flag: None, + selected_flag: None, + attachment_flag: None, } } } @@ -148,6 +172,10 @@ impl DotAddressable for ListingSettings { .sidebar_mailbox_tree_no_sibling_leaf .lookup(field, tail), "sidebar_divider" => self.sidebar_divider.lookup(field, tail), + "unseen_flag" => self.unseen_flag.lookup(field, tail), + "thread_snoozed_flag" => self.thread_snoozed_flag.lookup(field, tail), + "selected_flag" => self.selected_flag.lookup(field, tail), + "attachment_flag" => self.attachment_flag.lookup(field, tail), other => Err(MeliError::new(format!( "{} has no field named {}", parent_field, other diff --git a/src/conf/overrides.rs b/src/conf/overrides.rs index 67eea417..7629178a 100644 --- a/src/conf/overrides.rs +++ b/src/conf/overrides.rs @@ -138,6 +138,22 @@ pub struct ListingSettingsOverride { #[doc = "Default: ' '"] #[serde(default)] pub sidebar_divider: Option, + #[doc = " Flag to show if thread entry contains unseen mail."] + #[doc = " Default: \"●\""] + #[serde(default)] + pub unseen_flag: Option>, + #[doc = " Flag to show if thread has been snoozed."] + #[doc = " Default: \"💤\""] + #[serde(default)] + pub thread_snoozed_flag: Option>, + #[doc = " Flag to show if thread entry has been selected."] + #[doc = " Default: \"☑\u{fe0f}\""] + #[serde(default)] + pub selected_flag: Option>, + #[doc = " Flag to show if thread entry contains attachments."] + #[doc = " Default: \"📎\""] + #[serde(default)] + pub attachment_flag: Option>, } impl Default for ListingSettingsOverride { fn default() -> Self { @@ -153,6 +169,10 @@ impl Default for ListingSettingsOverride { sidebar_mailbox_tree_has_sibling_leaf: None, sidebar_mailbox_tree_no_sibling_leaf: None, sidebar_divider: None, + unseen_flag: None, + thread_snoozed_flag: None, + selected_flag: None, + attachment_flag: None, } } }