listing: add {unseen,selected,attachment,thread_snoozed} flag config values
parent
b411daddaa
commit
64b62352d0
|
@ -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,32 +938,68 @@ 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),
|
||||
}
|
||||
subject: if thread.len() > 1 {
|
||||
SubjectString(format!("{} ({})", subject, thread.len(),))
|
||||
} else {
|
||||
EntryStrings {
|
||||
date: DateString(ConversationsListing::format_date(context, thread.date())),
|
||||
subject: SubjectString(subject),
|
||||
SubjectString(subject)
|
||||
},
|
||||
flag: FlagString(format!(
|
||||
"{}{}",
|
||||
if thread.has_attachments() { "π" } else { "" },
|
||||
if thread.snoozed() { "π€" } else { "" }
|
||||
"{}{}{}{}",
|
||||
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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_thread_under_cursor(&self, cursor: usize) -> ThreadHash {
|
||||
if self.filter_term.is_empty() {
|
||||
|
|
|
@ -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<String>,
|
||||
|
||||
/// Flag to show if thread has been snoozed.
|
||||
/// Default: "π€"
|
||||
#[serde(default)]
|
||||
pub thread_snoozed_flag: Option<String>,
|
||||
|
||||
/// Flag to show if thread entry has been selected.
|
||||
/// Default: "βοΈ"
|
||||
#[serde(default)]
|
||||
pub selected_flag: Option<String>,
|
||||
|
||||
/// Flag to show if thread entry contains attachments.
|
||||
/// Default: "π"
|
||||
#[serde(default)]
|
||||
pub attachment_flag: Option<String>,
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -138,6 +138,22 @@ pub struct ListingSettingsOverride {
|
|||
#[doc = "Default: ' '"]
|
||||
#[serde(default)]
|
||||
pub sidebar_divider: Option<char>,
|
||||
#[doc = " Flag to show if thread entry contains unseen mail."]
|
||||
#[doc = " Default: \"β\""]
|
||||
#[serde(default)]
|
||||
pub unseen_flag: Option<Option<String>>,
|
||||
#[doc = " Flag to show if thread has been snoozed."]
|
||||
#[doc = " Default: \"π€\""]
|
||||
#[serde(default)]
|
||||
pub thread_snoozed_flag: Option<Option<String>>,
|
||||
#[doc = " Flag to show if thread entry has been selected."]
|
||||
#[doc = " Default: \"β\u{fe0f}\""]
|
||||
#[serde(default)]
|
||||
pub selected_flag: Option<Option<String>>,
|
||||
#[doc = " Flag to show if thread entry contains attachments."]
|
||||
#[doc = " Default: \"π\""]
|
||||
#[serde(default)]
|
||||
pub attachment_flag: Option<Option<String>>,
|
||||
}
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loadingβ¦
Reference in New Issue