meli: add deny clippy lints and fix them
Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>pull/338/head
parent
0270db0123
commit
8185f2cf7d
|
@ -192,7 +192,7 @@ use melib::HeaderName;
|
|||
#(#attrs_tokens)*
|
||||
impl Default for #override_ident {
|
||||
fn default() -> Self {
|
||||
#override_ident {
|
||||
Self {
|
||||
#(#field_idents: None),*
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,34 +287,34 @@ pub enum JobRequest {
|
|||
impl Drop for JobRequest {
|
||||
fn drop(&mut self) {
|
||||
match self {
|
||||
JobRequest::Generic { handle, .. } |
|
||||
JobRequest::IsOnline { handle, .. } |
|
||||
JobRequest::Refresh { handle, .. } |
|
||||
JobRequest::SetFlags { handle, .. } |
|
||||
JobRequest::SaveMessage { handle, .. } |
|
||||
Self::Generic { handle, .. } |
|
||||
Self::IsOnline { handle, .. } |
|
||||
Self::Refresh { handle, .. } |
|
||||
Self::SetFlags { handle, .. } |
|
||||
Self::SaveMessage { handle, .. } |
|
||||
//JobRequest::RenameMailbox,
|
||||
JobRequest::SetMailboxPermissions { handle, .. } |
|
||||
JobRequest::SetMailboxSubscription { handle, .. } |
|
||||
JobRequest::Watch { handle, .. } |
|
||||
JobRequest::SendMessageBackground { handle, .. } => {
|
||||
Self::SetMailboxPermissions { handle, .. } |
|
||||
Self::SetMailboxSubscription { handle, .. } |
|
||||
Self::Watch { handle, .. } |
|
||||
Self::SendMessageBackground { handle, .. } => {
|
||||
handle.cancel();
|
||||
}
|
||||
JobRequest::DeleteMessages { handle, .. } => {
|
||||
Self::DeleteMessages { handle, .. } => {
|
||||
handle.cancel();
|
||||
}
|
||||
JobRequest::CreateMailbox { handle, .. } => {
|
||||
Self::CreateMailbox { handle, .. } => {
|
||||
handle.cancel();
|
||||
}
|
||||
JobRequest::DeleteMailbox { handle, .. } => {
|
||||
Self::DeleteMailbox { handle, .. } => {
|
||||
handle.cancel();
|
||||
}
|
||||
JobRequest::Fetch { handle, .. } => {
|
||||
Self::Fetch { handle, .. } => {
|
||||
handle.cancel();
|
||||
}
|
||||
JobRequest::Mailboxes { handle, .. } => {
|
||||
Self::Mailboxes { handle, .. } => {
|
||||
handle.cancel();
|
||||
}
|
||||
JobRequest::SendMessage => {}
|
||||
Self::SendMessage => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -322,14 +322,14 @@ impl Drop for JobRequest {
|
|||
impl std::fmt::Debug for JobRequest {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
JobRequest::Generic { name, .. } => write!(f, "JobRequest::Generic({})", name),
|
||||
JobRequest::Mailboxes { .. } => write!(f, "JobRequest::Mailboxes"),
|
||||
JobRequest::Fetch { mailbox_hash, .. } => {
|
||||
Self::Generic { name, .. } => write!(f, "JobRequest::Generic({})", name),
|
||||
Self::Mailboxes { .. } => write!(f, "JobRequest::Mailboxes"),
|
||||
Self::Fetch { mailbox_hash, .. } => {
|
||||
write!(f, "JobRequest::Fetch({})", mailbox_hash)
|
||||
}
|
||||
JobRequest::IsOnline { .. } => write!(f, "JobRequest::IsOnline"),
|
||||
JobRequest::Refresh { .. } => write!(f, "JobRequest::Refresh"),
|
||||
JobRequest::SetFlags {
|
||||
Self::IsOnline { .. } => write!(f, "JobRequest::IsOnline"),
|
||||
Self::Refresh { .. } => write!(f, "JobRequest::Refresh"),
|
||||
Self::SetFlags {
|
||||
env_hashes,
|
||||
mailbox_hash,
|
||||
flags,
|
||||
|
@ -340,22 +340,22 @@ impl std::fmt::Debug for JobRequest {
|
|||
.field("mailbox_hash", &mailbox_hash)
|
||||
.field("flags", &flags)
|
||||
.finish(),
|
||||
JobRequest::SaveMessage { .. } => write!(f, "JobRequest::SaveMessage"),
|
||||
JobRequest::DeleteMessages { .. } => write!(f, "JobRequest::DeleteMessages"),
|
||||
JobRequest::CreateMailbox { .. } => write!(f, "JobRequest::CreateMailbox"),
|
||||
JobRequest::DeleteMailbox { mailbox_hash, .. } => {
|
||||
Self::SaveMessage { .. } => write!(f, "JobRequest::SaveMessage"),
|
||||
Self::DeleteMessages { .. } => write!(f, "JobRequest::DeleteMessages"),
|
||||
Self::CreateMailbox { .. } => write!(f, "JobRequest::CreateMailbox"),
|
||||
Self::DeleteMailbox { mailbox_hash, .. } => {
|
||||
write!(f, "JobRequest::DeleteMailbox({})", mailbox_hash)
|
||||
}
|
||||
//JobRequest::RenameMailbox,
|
||||
JobRequest::SetMailboxPermissions { .. } => {
|
||||
Self::SetMailboxPermissions { .. } => {
|
||||
write!(f, "JobRequest::SetMailboxPermissions")
|
||||
}
|
||||
JobRequest::SetMailboxSubscription { .. } => {
|
||||
Self::SetMailboxSubscription { .. } => {
|
||||
write!(f, "JobRequest::SetMailboxSubscription")
|
||||
}
|
||||
JobRequest::Watch { .. } => write!(f, "JobRequest::Watch"),
|
||||
JobRequest::SendMessage => write!(f, "JobRequest::SendMessage"),
|
||||
JobRequest::SendMessageBackground { .. } => {
|
||||
Self::Watch { .. } => write!(f, "JobRequest::Watch"),
|
||||
Self::SendMessage => write!(f, "JobRequest::SendMessage"),
|
||||
Self::SendMessageBackground { .. } => {
|
||||
write!(f, "JobRequest::SendMessageBackground")
|
||||
}
|
||||
}
|
||||
|
@ -365,12 +365,12 @@ impl std::fmt::Debug for JobRequest {
|
|||
impl std::fmt::Display for JobRequest {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
JobRequest::Generic { name, .. } => write!(f, "{}", name),
|
||||
JobRequest::Mailboxes { .. } => write!(f, "Get mailbox list"),
|
||||
JobRequest::Fetch { .. } => write!(f, "Mailbox fetch"),
|
||||
JobRequest::IsOnline { .. } => write!(f, "Online status check"),
|
||||
JobRequest::Refresh { .. } => write!(f, "Refresh mailbox"),
|
||||
JobRequest::SetFlags {
|
||||
Self::Generic { name, .. } => write!(f, "{}", name),
|
||||
Self::Mailboxes { .. } => write!(f, "Get mailbox list"),
|
||||
Self::Fetch { .. } => write!(f, "Mailbox fetch"),
|
||||
Self::IsOnline { .. } => write!(f, "Online status check"),
|
||||
Self::Refresh { .. } => write!(f, "Refresh mailbox"),
|
||||
Self::SetFlags {
|
||||
env_hashes, flags, ..
|
||||
} => write!(
|
||||
f,
|
||||
|
@ -379,20 +379,20 @@ impl std::fmt::Display for JobRequest {
|
|||
if env_hashes.len() == 1 { "" } else { "s" },
|
||||
flags
|
||||
),
|
||||
JobRequest::SaveMessage { .. } => write!(f, "Save message"),
|
||||
JobRequest::DeleteMessages { env_hashes, .. } => write!(
|
||||
Self::SaveMessage { .. } => write!(f, "Save message"),
|
||||
Self::DeleteMessages { env_hashes, .. } => write!(
|
||||
f,
|
||||
"Delete {} message{}",
|
||||
env_hashes.len(),
|
||||
if env_hashes.len() == 1 { "" } else { "s" }
|
||||
),
|
||||
JobRequest::CreateMailbox { path, .. } => write!(f, "Create mailbox {}", path),
|
||||
JobRequest::DeleteMailbox { .. } => write!(f, "Delete mailbox"),
|
||||
Self::CreateMailbox { path, .. } => write!(f, "Create mailbox {}", path),
|
||||
Self::DeleteMailbox { .. } => write!(f, "Delete mailbox"),
|
||||
//JobRequest::RenameMailbox,
|
||||
JobRequest::SetMailboxPermissions { .. } => write!(f, "Set mailbox permissions"),
|
||||
JobRequest::SetMailboxSubscription { .. } => write!(f, "Set mailbox subscription"),
|
||||
JobRequest::Watch { .. } => write!(f, "Background watch"),
|
||||
JobRequest::SendMessageBackground { .. } | JobRequest::SendMessage => {
|
||||
Self::SetMailboxPermissions { .. } => write!(f, "Set mailbox permissions"),
|
||||
Self::SetMailboxSubscription { .. } => write!(f, "Set mailbox subscription"),
|
||||
Self::Watch { .. } => write!(f, "Background watch"),
|
||||
Self::SendMessageBackground { .. } | Self::SendMessage => {
|
||||
write!(f, "Sending message")
|
||||
}
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ impl JobRequest {
|
|||
is_variant! { is_online, IsOnline { .. } }
|
||||
|
||||
pub fn is_fetch(&self, mailbox_hash: MailboxHash) -> bool {
|
||||
matches!(self, JobRequest::Fetch {
|
||||
matches!(self, Self::Fetch {
|
||||
mailbox_hash: h, ..
|
||||
} if *h == mailbox_hash)
|
||||
}
|
||||
|
@ -578,7 +578,7 @@ impl Account {
|
|||
}
|
||||
}
|
||||
|
||||
Ok(Account {
|
||||
Ok(Self {
|
||||
hash,
|
||||
name,
|
||||
is_online: if !backend.capabilities().is_remote {
|
||||
|
@ -1590,7 +1590,7 @@ impl Account {
|
|||
*retries *= 2;
|
||||
}
|
||||
Some(Duration::from_millis(
|
||||
oldval * (4 * melib::utils::random::random_u8() as u64),
|
||||
oldval * (4 * u64::from(melib::utils::random::random_u8())),
|
||||
))
|
||||
} else {
|
||||
None
|
||||
|
@ -2531,11 +2531,9 @@ fn build_mailboxes_order(
|
|||
.collect::<SmallVec<[_; 8]>>()
|
||||
.into_iter()
|
||||
.peekable();
|
||||
indentation <<= 1;
|
||||
if has_sibling {
|
||||
indentation <<= 1;
|
||||
indentation |= 1;
|
||||
} else {
|
||||
indentation <<= 1;
|
||||
}
|
||||
while let Some(i) = iter.next() {
|
||||
let c = &mut node.children[i];
|
||||
|
|
|
@ -60,7 +60,7 @@ impl Account {
|
|||
pub(super) fn update_cached_env(&mut self, env: Envelope, old_hash: Option<EnvelopeHash>) {
|
||||
if self.settings.conf.search_backend == crate::conf::SearchBackend::Sqlite3 {
|
||||
let msg_id = env.message_id_display().to_string();
|
||||
match crate::sqlite3::remove(old_hash.unwrap_or(env.hash()))
|
||||
match crate::sqlite3::remove(old_hash.unwrap_or_else(|| env.hash()))
|
||||
.map(|_| crate::sqlite3::insert(env, self.backend.clone(), self.name.clone()))
|
||||
{
|
||||
Ok(job) => {
|
||||
|
|
|
@ -179,10 +179,10 @@ pub mod manpages {
|
|||
};
|
||||
|
||||
for (p, dir) in [
|
||||
(ManPages::Main, "man1"),
|
||||
(ManPages::Conf, "man5"),
|
||||
(ManPages::Themes, "man5"),
|
||||
(ManPages::Guide, "man7"),
|
||||
(Self::Main, "man1"),
|
||||
(Self::Conf, "man5"),
|
||||
(Self::Themes, "man5"),
|
||||
(Self::Guide, "man7"),
|
||||
] {
|
||||
let text = crate::subcommands::man(p, true)?;
|
||||
path.push(dir);
|
||||
|
|
|
@ -503,7 +503,7 @@ Alternatives(&[to_stream!(One(Literal("add-attachment")), One(Filepath)), to_str
|
|||
/// Get command suggestions for input
|
||||
pub fn command_completion_suggestions(input: &str) -> Vec<String> {
|
||||
use crate::melib::ShellExpandTrait;
|
||||
let mut sugg = Default::default();
|
||||
let mut sugg: HashSet<String> = Default::default();
|
||||
for (_tags, _desc, tokens, _) in COMMAND_COMPLETION.iter() {
|
||||
let _m = tokens.matches(&mut &(*input), &mut sugg);
|
||||
if _m.is_empty() {
|
||||
|
@ -528,17 +528,15 @@ mod tests {
|
|||
let mut input = "sort".to_string();
|
||||
macro_rules! match_input {
|
||||
($input:expr) => {{
|
||||
let mut sugg = Default::default();
|
||||
let mut vec = vec![];
|
||||
let mut sugg: HashSet<String> = Default::default();
|
||||
//print!("{}", $input);
|
||||
for (_tags, _desc, tokens, _) in COMMAND_COMPLETION.iter() {
|
||||
//println!("{:?}, {:?}, {:?}", _tags, _desc, tokens);
|
||||
let m = tokens.matches(&mut $input.as_str(), &mut sugg);
|
||||
if !m.is_empty() {
|
||||
vec.push(tokens);
|
||||
//print!("{:?} ", desc);
|
||||
//println!(" result = {:#?}\n\n", m);
|
||||
}
|
||||
// //println!("{:?}, {:?}, {:?}", _tags, _desc, tokens);
|
||||
let _ = tokens.matches(&mut $input.as_str(), &mut sugg);
|
||||
// if !m.is_empty() {
|
||||
// //print!("{:?} ", desc);
|
||||
// //println!(" result = {:#?}\n\n", m);
|
||||
// }
|
||||
}
|
||||
//println!("suggestions = {:#?}", sugg);
|
||||
sugg.into_iter()
|
||||
|
@ -587,7 +585,7 @@ mod tests {
|
|||
match io::stdin().read_line(&mut input) {
|
||||
Ok(_n) => {
|
||||
println!("Input is {:?}", input.as_str().trim());
|
||||
let mut sugg = Default::default();
|
||||
let mut sugg: HashSet<String> = Default::default();
|
||||
let mut vec = vec![];
|
||||
//print!("{}", input);
|
||||
for (_tags, _desc, tokens, _) in COMMAND_COMPLETION.iter() {
|
||||
|
|
|
@ -143,10 +143,10 @@ impl Action {
|
|||
pub fn needs_confirmation(&self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Action::Listing(ListingAction::Delete)
|
||||
| Action::MailingListAction(_)
|
||||
| Action::Mailbox(_, _)
|
||||
| Action::Quit
|
||||
Self::Listing(ListingAction::Delete)
|
||||
| Self::MailingListAction(_)
|
||||
| Self::Mailbox(_, _)
|
||||
| Self::Quit
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,7 +279,7 @@ impl From<FileAccount> for AccountConf {
|
|||
};
|
||||
|
||||
let mailbox_confs = x.mailboxes.clone();
|
||||
AccountConf {
|
||||
Self {
|
||||
account: acc,
|
||||
conf_override: x.conf_override.clone(),
|
||||
conf: x,
|
||||
|
@ -393,7 +393,7 @@ define(`include', `builtin_include(substr($1,1,decr(decr(len($1)))))dnl')dnl
|
|||
file.read_to_string(&mut contents)?;
|
||||
|
||||
let mut handle = Command::new("m4")
|
||||
.current_dir(conf_path.parent().unwrap_or(Path::new("/")))
|
||||
.current_dir(conf_path.parent().unwrap_or_else(|| Path::new("/")))
|
||||
.stdin(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
|
@ -407,7 +407,7 @@ define(`include', `builtin_include(substr($1,1,decr(decr(len($1)))))dnl')dnl
|
|||
}
|
||||
|
||||
impl FileSettings {
|
||||
pub fn new() -> Result<FileSettings> {
|
||||
pub fn new() -> Result<Self> {
|
||||
let config_path = get_config_file()?;
|
||||
if !config_path.exists() {
|
||||
let path_string = config_path.display().to_string();
|
||||
|
@ -429,12 +429,12 @@ impl FileSettings {
|
|||
));
|
||||
}
|
||||
#[cfg(test)]
|
||||
return Ok(FileSettings::default());
|
||||
return Ok(Self::default());
|
||||
#[cfg(not(test))]
|
||||
return Err(Error::new("No configuration file found."));
|
||||
}
|
||||
|
||||
FileSettings::validate(config_path, true, false)
|
||||
Self::validate(config_path, true, false)
|
||||
}
|
||||
|
||||
pub fn validate(path: PathBuf, interactive: bool, clear_extras: bool) -> Result<Self> {
|
||||
|
@ -467,11 +467,11 @@ This is required so that you don't accidentally start meli and find out later th
|
|||
};
|
||||
if ask.run() {
|
||||
let mut file = OpenOptions::new().append(true).open(&path)?;
|
||||
file.write_all("[composing]\nsend_mail = 'false'\n".as_bytes())
|
||||
file.write_all(b"[composing]\nsend_mail = 'false'\n")
|
||||
.map_err(|err| {
|
||||
Error::new(format!("Could not append to {}: {}", path.display(), err))
|
||||
})?;
|
||||
return FileSettings::validate(path, interactive, clear_extras);
|
||||
return Self::validate(path, interactive, clear_extras);
|
||||
}
|
||||
}
|
||||
return Err(Error::new(format!(
|
||||
|
@ -480,7 +480,7 @@ This is required so that you don't accidentally start meli and find out later th
|
|||
path.display()
|
||||
)));
|
||||
}
|
||||
let mut s: FileSettings = toml::from_str(&s).map_err(|err| {
|
||||
let mut s: Self = toml::from_str(&s).map_err(|err| {
|
||||
Error::new(format!(
|
||||
"{}: Config file contains errors; {}",
|
||||
path.display(),
|
||||
|
@ -588,7 +588,7 @@ pub struct Settings {
|
|||
}
|
||||
|
||||
impl Settings {
|
||||
pub fn new() -> Result<Settings> {
|
||||
pub fn new() -> Result<Self> {
|
||||
let fs = FileSettings::new()?;
|
||||
let mut s: IndexMap<String, AccountConf> = IndexMap::new();
|
||||
|
||||
|
@ -605,7 +605,7 @@ impl Settings {
|
|||
_logger.change_log_dest(log_path.into());
|
||||
}
|
||||
|
||||
Ok(Settings {
|
||||
Ok(Self {
|
||||
accounts: s,
|
||||
pager: fs.pager,
|
||||
listing: fs.listing,
|
||||
|
@ -620,7 +620,7 @@ impl Settings {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn without_accounts() -> Result<Settings> {
|
||||
pub fn without_accounts() -> Result<Self> {
|
||||
let fs = FileSettings::new()?;
|
||||
let mut _logger = StderrLogger::new(fs.log.maximum_level);
|
||||
|
||||
|
@ -628,7 +628,7 @@ impl Settings {
|
|||
_logger.change_log_dest(log_path.into());
|
||||
}
|
||||
|
||||
Ok(Settings {
|
||||
Ok(Self {
|
||||
accounts: IndexMap::new(),
|
||||
pager: fs.pager,
|
||||
listing: fs.listing,
|
||||
|
@ -761,10 +761,10 @@ impl<'de> Deserialize<'de> for IndexStyle {
|
|||
{
|
||||
let s = <String>::deserialize(deserializer)?;
|
||||
match s.as_str() {
|
||||
"Plain" | "plain" => Ok(IndexStyle::Plain),
|
||||
"Threaded" | "threaded" => Ok(IndexStyle::Threaded),
|
||||
"Compact" | "compact" => Ok(IndexStyle::Compact),
|
||||
"Conversations" | "conversations" => Ok(IndexStyle::Conversations),
|
||||
"Plain" | "plain" => Ok(Self::Plain),
|
||||
"Threaded" | "threaded" => Ok(Self::Threaded),
|
||||
"Compact" | "compact" => Ok(Self::Compact),
|
||||
"Conversations" | "conversations" => Ok(Self::Conversations),
|
||||
_ => Err(de::Error::custom("invalid `index_style` value")),
|
||||
}
|
||||
}
|
||||
|
@ -776,10 +776,10 @@ impl Serialize for IndexStyle {
|
|||
S: Serializer,
|
||||
{
|
||||
match self {
|
||||
IndexStyle::Plain => serializer.serialize_str("plain"),
|
||||
IndexStyle::Threaded => serializer.serialize_str("threaded"),
|
||||
IndexStyle::Compact => serializer.serialize_str("compact"),
|
||||
IndexStyle::Conversations => serializer.serialize_str("conversations"),
|
||||
Self::Plain => serializer.serialize_str("plain"),
|
||||
Self::Threaded => serializer.serialize_str("threaded"),
|
||||
Self::Compact => serializer.serialize_str("compact"),
|
||||
Self::Conversations => serializer.serialize_str("conversations"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -805,15 +805,15 @@ impl<'de> Deserialize<'de> for SearchBackend {
|
|||
if sqlite3.eq_ignore_ascii_case("sqlite3")
|
||||
|| sqlite3.eq_ignore_ascii_case("sqlite") =>
|
||||
{
|
||||
Ok(SearchBackend::Sqlite3)
|
||||
Ok(Self::Sqlite3)
|
||||
}
|
||||
none if none.eq_ignore_ascii_case("none")
|
||||
|| none.eq_ignore_ascii_case("nothing")
|
||||
|| none.is_empty() =>
|
||||
{
|
||||
Ok(SearchBackend::None)
|
||||
Ok(Self::None)
|
||||
}
|
||||
auto if auto.eq_ignore_ascii_case("auto") => Ok(SearchBackend::Auto),
|
||||
auto if auto.eq_ignore_ascii_case("auto") => Ok(Self::Auto),
|
||||
_ => Err(de::Error::custom("invalid `search_backend` value")),
|
||||
}
|
||||
}
|
||||
|
@ -826,9 +826,9 @@ impl Serialize for SearchBackend {
|
|||
{
|
||||
match self {
|
||||
#[cfg(feature = "sqlite3")]
|
||||
SearchBackend::Sqlite3 => serializer.serialize_str("sqlite3"),
|
||||
SearchBackend::None => serializer.serialize_str("none"),
|
||||
SearchBackend::Auto => serializer.serialize_str("auto"),
|
||||
Self::Sqlite3 => serializer.serialize_str("sqlite3"),
|
||||
Self::None => serializer.serialize_str("none"),
|
||||
Self::Auto => serializer.serialize_str("auto"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1332,7 +1332,7 @@ send_mail = 'false'
|
|||
.append(true)
|
||||
.open(&path)?;
|
||||
file.write_all(content.as_bytes())?;
|
||||
Ok(ConfigFile { path, file })
|
||||
Ok(Self { path, file })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1350,7 +1350,7 @@ send_mail = 'false'
|
|||
));
|
||||
new_file
|
||||
.file
|
||||
.write_all("[composing]\nsend_mail = 'false'\n".as_bytes())
|
||||
.write_all(b"[composing]\nsend_mail = 'false'\n")
|
||||
.unwrap();
|
||||
let err = FileSettings::validate(new_file.path.clone(), false, true).unwrap_err();
|
||||
assert_eq!(
|
||||
|
|
|
@ -115,7 +115,7 @@ pub struct ComposingSettings {
|
|||
|
||||
impl Default for ComposingSettings {
|
||||
fn default() -> Self {
|
||||
ComposingSettings {
|
||||
Self {
|
||||
send_mail: SendMail::ShellCommand("false".into()),
|
||||
editor_command: None,
|
||||
embedded_pty: false,
|
||||
|
@ -296,9 +296,9 @@ impl<'de> Deserialize<'de> for SendMail {
|
|||
|
||||
match <SendMailInner>::deserialize(deserializer) {
|
||||
#[cfg(feature = "smtp")]
|
||||
Ok(SendMailInner::Smtp(v)) => Ok(SendMail::Smtp(v)),
|
||||
Ok(SendMailInner::ServerSubmission) => Ok(SendMail::ServerSubmission),
|
||||
Ok(SendMailInner::ShellCommand(v)) => Ok(SendMail::ShellCommand(v)),
|
||||
Ok(SendMailInner::Smtp(v)) => Ok(Self::Smtp(v)),
|
||||
Ok(SendMailInner::ServerSubmission) => Ok(Self::ServerSubmission),
|
||||
Ok(SendMailInner::ShellCommand(v)) => Ok(Self::ShellCommand(v)),
|
||||
Err(_err) => Err(de::Error::custom(SENDMAIL_ERR_HELP)),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,17 +27,17 @@
|
|||
use super::*;
|
||||
use melib::HeaderName;
|
||||
|
||||
# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct PagerSettingsOverride { # [doc = " Number of context lines when going to next page."] # [doc = " Default: 0"] # [serde (alias = "pager-context")] # [serde (default)] pub pager_context : Option < usize > , # [doc = " Stop at the end instead of displaying next mail."] # [doc = " Default: false"] # [serde (alias = "pager-stop")] # [serde (default)] pub pager_stop : Option < bool > , # [doc = " Always show headers when scrolling."] # [doc = " Default: true"] # [serde (alias = "sticky-headers" , alias = "headers-sticky" , alias = "headers_sticky")] # [serde (default)] pub sticky_headers : Option < bool > , # [doc = " The height of the pager in mail view, in percent."] # [doc = " Default: 80"] # [serde (alias = "pager-ratio")] # [serde (default)] pub pager_ratio : Option < usize > , # [doc = " A command to pipe mail output through for viewing in pager."] # [doc = " Default: None"] # [serde (deserialize_with = "non_empty_opt_string")] # [serde (default)] pub filter : Option < Option < String > > , # [doc = " A command to pipe html output before displaying it in a pager"] # [doc = " Default: None"] # [serde (deserialize_with = "non_empty_opt_string" , alias = "html-filter")] # [serde (default)] pub html_filter : Option < Option < String > > , # [doc = " Respect \"format=flowed\""] # [doc = " Default: true"] # [serde (alias = "format-flowed")] # [serde (default)] pub format_flowed : Option < bool > , # [doc = " Split long lines that would overflow on the x axis."] # [doc = " Default: true"] # [serde (alias = "split-long-lines")] # [serde (default)] pub split_long_lines : Option < bool > , # [doc = " Minimum text width in columns."] # [doc = " Default: 80"] # [serde (alias = "minimum-width")] # [serde (default)] pub minimum_width : Option < usize > , # [doc = " Choose `text/html` alternative if `text/plain` is empty in"] # [doc = " `multipart/alternative` attachments."] # [doc = " Default: true"] # [serde (alias = "auto-choose-multipart-alternative")] # [serde (default)] pub auto_choose_multipart_alternative : Option < ToggleFlag > , # [doc = " Show Date: in my timezone"] # [doc = " Default: true"] # [serde (alias = "show-date-in-my-timezone")] # [serde (default)] pub show_date_in_my_timezone : Option < ToggleFlag > , # [doc = " A command to launch URLs with. The URL will be given as the first"] # [doc = " argument of the command. Default: None"] # [serde (deserialize_with = "non_empty_opt_string")] # [serde (default)] pub url_launcher : Option < Option < String > > , # [doc = " A command to open html files."] # [doc = " Default: None"] # [serde (deserialize_with = "non_empty_opt_string" , alias = "html-open")] # [serde (default)] pub html_open : Option < Option < String > > , # [doc = " Extra headers to display, if present, in the default header preamble."] # [doc = " Default: []"] # [serde (alias = "show-extra-headers")] # [serde (default)] pub show_extra_headers : Option < Vec < String > > } impl Default for PagerSettingsOverride { fn default () -> Self { PagerSettingsOverride { pager_context : None , pager_stop : None , sticky_headers : None , pager_ratio : None , filter : None , html_filter : None , format_flowed : None , split_long_lines : None , minimum_width : None , auto_choose_multipart_alternative : None , show_date_in_my_timezone : None , url_launcher : None , html_open : None , show_extra_headers : None } } }
|
||||
# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct PagerSettingsOverride { # [doc = " Number of context lines when going to next page."] # [doc = " Default: 0"] # [serde (alias = "pager-context")] # [serde (default)] pub pager_context : Option < usize > , # [doc = " Stop at the end instead of displaying next mail."] # [doc = " Default: false"] # [serde (alias = "pager-stop")] # [serde (default)] pub pager_stop : Option < bool > , # [doc = " Always show headers when scrolling."] # [doc = " Default: true"] # [serde (alias = "sticky-headers" , alias = "headers-sticky" , alias = "headers_sticky")] # [serde (default)] pub sticky_headers : Option < bool > , # [doc = " The height of the pager in mail view, in percent."] # [doc = " Default: 80"] # [serde (alias = "pager-ratio")] # [serde (default)] pub pager_ratio : Option < usize > , # [doc = " A command to pipe mail output through for viewing in pager."] # [doc = " Default: None"] # [serde (deserialize_with = "non_empty_opt_string")] # [serde (default)] pub filter : Option < Option < String > > , # [doc = " A command to pipe html output before displaying it in a pager"] # [doc = " Default: None"] # [serde (deserialize_with = "non_empty_opt_string" , alias = "html-filter")] # [serde (default)] pub html_filter : Option < Option < String > > , # [doc = " Respect \"format=flowed\""] # [doc = " Default: true"] # [serde (alias = "format-flowed")] # [serde (default)] pub format_flowed : Option < bool > , # [doc = " Split long lines that would overflow on the x axis."] # [doc = " Default: true"] # [serde (alias = "split-long-lines")] # [serde (default)] pub split_long_lines : Option < bool > , # [doc = " Minimum text width in columns."] # [doc = " Default: 80"] # [serde (alias = "minimum-width")] # [serde (default)] pub minimum_width : Option < usize > , # [doc = " Choose `text/html` alternative if `text/plain` is empty in"] # [doc = " `multipart/alternative` attachments."] # [doc = " Default: true"] # [serde (alias = "auto-choose-multipart-alternative")] # [serde (default)] pub auto_choose_multipart_alternative : Option < ToggleFlag > , # [doc = " Show Date: in my timezone"] # [doc = " Default: true"] # [serde (alias = "show-date-in-my-timezone")] # [serde (default)] pub show_date_in_my_timezone : Option < ToggleFlag > , # [doc = " A command to launch URLs with. The URL will be given as the first"] # [doc = " argument of the command. Default: None"] # [serde (deserialize_with = "non_empty_opt_string")] # [serde (default)] pub url_launcher : Option < Option < String > > , # [doc = " A command to open html files."] # [doc = " Default: None"] # [serde (deserialize_with = "non_empty_opt_string" , alias = "html-open")] # [serde (default)] pub html_open : Option < Option < String > > , # [doc = " Extra headers to display, if present, in the default header preamble."] # [doc = " Default: []"] # [serde (alias = "show-extra-headers")] # [serde (default)] pub show_extra_headers : Option < Vec < String > > } impl Default for PagerSettingsOverride { fn default () -> Self { Self { pager_context : None , pager_stop : None , sticky_headers : None , pager_ratio : None , filter : None , html_filter : None , format_flowed : None , split_long_lines : None , minimum_width : None , auto_choose_multipart_alternative : None , show_date_in_my_timezone : None , url_launcher : None , html_open : None , show_extra_headers : None } } }
|
||||
|
||||
# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct ListingSettingsOverride { # [doc = " Number of context lines when going to next page."] # [doc = " Default: 0"] # [serde (alias = "context-lines")] # [serde (default)] pub context_lines : Option < usize > , # [doc = " Show auto-hiding scrollbar in accounts sidebar menu."] # [doc = " Default: True"] # [serde (default)] pub show_menu_scrollbar : Option < bool > , # [doc = " Datetime formatting passed verbatim to strftime(3)."] # [doc = " Default: %Y-%m-%d %T"] # [serde (alias = "datetime-fmt")] # [serde (default)] pub datetime_fmt : Option < Option < String > > , # [doc = " Show recent dates as `X {minutes,hours,days} ago`, up to 7 days."] # [doc = " Default: true"] # [serde (alias = "recent-dates")] # [serde (default)] pub recent_dates : Option < bool > , # [doc = " Show only envelopes that match this query"] # [doc = " Default: None"] # [serde (default)] pub filter : Option < Option < Query > > , # [serde (alias = "index-style")] # [serde (default)] pub index_style : Option < IndexStyle > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_has_sibling : Option < Option < String > > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_no_sibling : Option < Option < String > > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_has_sibling_leaf : Option < Option < String > > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_no_sibling_leaf : Option < Option < String > > , # [doc = " Default: ' '"] # [serde (default)] pub sidebar_divider : Option < char > , # [doc = " Default: 90"] # [serde (default)] pub sidebar_ratio : Option < usize > , # [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 > > , # [doc = " Should threads with different Subjects show a list of those"] # [doc = " subjects on the entry title?"] # [doc = " Default: \"true\""] # [serde (default)] pub thread_subject_pack : Option < bool > , # [doc = " In threaded listing style, repeat identical From column values within a"] # [doc = " thread. Not repeating adds empty space in the From column which"] # [doc = " might result in less visual clutter."] # [doc = " Default: \"false\""] # [serde (default)] pub threaded_repeat_identical_from_values : Option < bool > , # [doc = " Show relative indices in menu mailboxes to quickly help with jumping to"] # [doc = " them. Default: \"true\""] # [serde (alias = "relative-menu-indices")] # [serde (default)] pub relative_menu_indices : Option < bool > , # [doc = " Show relative indices in listings to quickly help with jumping to"] # [doc = " them. Default: \"true\""] # [serde (alias = "relative-list-indices")] # [serde (default)] pub relative_list_indices : Option < bool > , # [doc = " Hide sidebar on launch. Default: \"false\""] # [serde (alias = "hide-sidebar-on-launch")] # [serde (default)] pub hide_sidebar_on_launch : Option < bool > } impl Default for ListingSettingsOverride { fn default () -> Self { ListingSettingsOverride { context_lines : None , show_menu_scrollbar : None , datetime_fmt : None , recent_dates : None , filter : None , index_style : None , sidebar_mailbox_tree_has_sibling : None , sidebar_mailbox_tree_no_sibling : None , sidebar_mailbox_tree_has_sibling_leaf : None , sidebar_mailbox_tree_no_sibling_leaf : None , sidebar_divider : None , sidebar_ratio : None , unseen_flag : None , thread_snoozed_flag : None , selected_flag : None , attachment_flag : None , thread_subject_pack : None , threaded_repeat_identical_from_values : None , relative_menu_indices : None , relative_list_indices : None , hide_sidebar_on_launch : None } } }
|
||||
# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct ListingSettingsOverride { # [doc = " Number of context lines when going to next page."] # [doc = " Default: 0"] # [serde (alias = "context-lines")] # [serde (default)] pub context_lines : Option < usize > , # [doc = " Show auto-hiding scrollbar in accounts sidebar menu."] # [doc = " Default: True"] # [serde (default)] pub show_menu_scrollbar : Option < bool > , # [doc = " Datetime formatting passed verbatim to strftime(3)."] # [doc = " Default: %Y-%m-%d %T"] # [serde (alias = "datetime-fmt")] # [serde (default)] pub datetime_fmt : Option < Option < String > > , # [doc = " Show recent dates as `X {minutes,hours,days} ago`, up to 7 days."] # [doc = " Default: true"] # [serde (alias = "recent-dates")] # [serde (default)] pub recent_dates : Option < bool > , # [doc = " Show only envelopes that match this query"] # [doc = " Default: None"] # [serde (default)] pub filter : Option < Option < Query > > , # [serde (alias = "index-style")] # [serde (default)] pub index_style : Option < IndexStyle > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_has_sibling : Option < Option < String > > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_no_sibling : Option < Option < String > > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_has_sibling_leaf : Option < Option < String > > , # [doc = " Default: \" \""] # [serde (default)] pub sidebar_mailbox_tree_no_sibling_leaf : Option < Option < String > > , # [doc = " Default: ' '"] # [serde (default)] pub sidebar_divider : Option < char > , # [doc = " Default: 90"] # [serde (default)] pub sidebar_ratio : Option < usize > , # [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 > > , # [doc = " Should threads with different Subjects show a list of those"] # [doc = " subjects on the entry title?"] # [doc = " Default: \"true\""] # [serde (default)] pub thread_subject_pack : Option < bool > , # [doc = " In threaded listing style, repeat identical From column values within a"] # [doc = " thread. Not repeating adds empty space in the From column which"] # [doc = " might result in less visual clutter."] # [doc = " Default: \"false\""] # [serde (default)] pub threaded_repeat_identical_from_values : Option < bool > , # [doc = " Show relative indices in menu mailboxes to quickly help with jumping to"] # [doc = " them. Default: \"true\""] # [serde (alias = "relative-menu-indices")] # [serde (default)] pub relative_menu_indices : Option < bool > , # [doc = " Show relative indices in listings to quickly help with jumping to"] # [doc = " them. Default: \"true\""] # [serde (alias = "relative-list-indices")] # [serde (default)] pub relative_list_indices : Option < bool > , # [doc = " Hide sidebar on launch. Default: \"false\""] # [serde (alias = "hide-sidebar-on-launch")] # [serde (default)] pub hide_sidebar_on_launch : Option < bool > } impl Default for ListingSettingsOverride { fn default () -> Self { Self { context_lines : None , show_menu_scrollbar : None , datetime_fmt : None , recent_dates : None , filter : None , index_style : None , sidebar_mailbox_tree_has_sibling : None , sidebar_mailbox_tree_no_sibling : None , sidebar_mailbox_tree_has_sibling_leaf : None , sidebar_mailbox_tree_no_sibling_leaf : None , sidebar_divider : None , sidebar_ratio : None , unseen_flag : None , thread_snoozed_flag : None , selected_flag : None , attachment_flag : None , thread_subject_pack : None , threaded_repeat_identical_from_values : None , relative_menu_indices : None , relative_list_indices : None , hide_sidebar_on_launch : None } } }
|
||||
|
||||
# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct NotificationsSettingsOverride { # [doc = " Enable notifications."] # [doc = " Default: True"] # [serde (default)] pub enable : Option < bool > , # [doc = " A command to pipe notifications through."] # [doc = " Default: None"] # [serde (default)] pub script : Option < Option < String > > , # [doc = " A command to pipe new mail notifications through (preferred over"] # [doc = " `script`). Default: None"] # [serde (default)] pub new_mail_script : Option < Option < String > > , # [doc = " A file location which has its size changed when new mail arrives (max"] # [doc = " 128 bytes). Can be used to trigger new mail notifications eg with"] # [doc = " `xbiff(1)`. Default: None"] # [serde (alias = "xbiff-file-path")] # [serde (default)] pub xbiff_file_path : Option < Option < String > > , # [serde (alias = "play-sound")] # [serde (default)] pub play_sound : Option < ToggleFlag > , # [serde (alias = "sound-file")] # [serde (default)] pub sound_file : Option < Option < String > > } impl Default for NotificationsSettingsOverride { fn default () -> Self { NotificationsSettingsOverride { enable : None , script : None , new_mail_script : None , xbiff_file_path : None , play_sound : None , sound_file : None } } }
|
||||
# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct NotificationsSettingsOverride { # [doc = " Enable notifications."] # [doc = " Default: True"] # [serde (default)] pub enable : Option < bool > , # [doc = " A command to pipe notifications through."] # [doc = " Default: None"] # [serde (default)] pub script : Option < Option < String > > , # [doc = " A command to pipe new mail notifications through (preferred over"] # [doc = " `script`). Default: None"] # [serde (default)] pub new_mail_script : Option < Option < String > > , # [doc = " A file location which has its size changed when new mail arrives (max"] # [doc = " 128 bytes). Can be used to trigger new mail notifications eg with"] # [doc = " `xbiff(1)`. Default: None"] # [serde (alias = "xbiff-file-path")] # [serde (default)] pub xbiff_file_path : Option < Option < String > > , # [serde (alias = "play-sound")] # [serde (default)] pub play_sound : Option < ToggleFlag > , # [serde (alias = "sound-file")] # [serde (default)] pub sound_file : Option < Option < String > > } impl Default for NotificationsSettingsOverride { fn default () -> Self { Self { enable : None , script : None , new_mail_script : None , xbiff_file_path : None , play_sound : None , sound_file : None } } }
|
||||
|
||||
# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct ShortcutsOverride { # [serde (default)] pub general : Option < GeneralShortcuts > , # [serde (default)] pub listing : Option < ListingShortcuts > , # [serde (default)] pub composing : Option < ComposingShortcuts > , # [serde (alias = "contact-list")] # [serde (default)] pub contact_list : Option < ContactListShortcuts > , # [serde (alias = "envelope-view")] # [serde (default)] pub envelope_view : Option < EnvelopeViewShortcuts > , # [serde (alias = "thread-view")] # [serde (default)] pub thread_view : Option < ThreadViewShortcuts > , # [serde (default)] pub pager : Option < PagerShortcuts > } impl Default for ShortcutsOverride { fn default () -> Self { ShortcutsOverride { general : None , listing : None , composing : None , contact_list : None , envelope_view : None , thread_view : None , pager : None } } }
|
||||
# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct ShortcutsOverride { # [serde (default)] pub general : Option < GeneralShortcuts > , # [serde (default)] pub listing : Option < ListingShortcuts > , # [serde (default)] pub composing : Option < ComposingShortcuts > , # [serde (alias = "contact-list")] # [serde (default)] pub contact_list : Option < ContactListShortcuts > , # [serde (alias = "envelope-view")] # [serde (default)] pub envelope_view : Option < EnvelopeViewShortcuts > , # [serde (alias = "thread-view")] # [serde (default)] pub thread_view : Option < ThreadViewShortcuts > , # [serde (default)] pub pager : Option < PagerShortcuts > } impl Default for ShortcutsOverride { fn default () -> Self { Self { general : None , listing : None , composing : None , contact_list : None , envelope_view : None , thread_view : None , pager : None } } }
|
||||
|
||||
# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct ComposingSettingsOverride { # [doc = " A command to pipe new emails to"] # [doc = " Required"] # [serde (default)] pub send_mail : Option < SendMail > , # [doc = " Command to launch editor. Can have arguments. Draft filename is given as"] # [doc = " the last argument. If it's missing, the environment variable $EDITOR is"] # [doc = " looked up."] # [serde (alias = "editor-command" , alias = "editor-cmd" , alias = "editor_cmd")] # [serde (default)] pub editor_command : Option < Option < String > > , # [doc = " Embedded editor (for terminal interfaces) instead of forking and"] # [doc = " waiting."] # [serde (alias = "embed")] # [serde (default)] pub embedded_pty : Option < bool > , # [doc = " Set \"format=flowed\" in plain text attachments."] # [doc = " Default: true"] # [serde (alias = "format-flowed")] # [serde (default)] pub format_flowed : Option < bool > , # [doc = " Set User-Agent"] # [doc = " Default: empty"] # [serde (alias = "insert_user_agent")] # [serde (default)] pub insert_user_agent : Option < bool > , # [doc = " Set default header values for new drafts"] # [doc = " Default: empty"] # [serde (alias = "default-header-values")] # [serde (default)] pub default_header_values : Option < HashMap < HeaderName , String > > , # [doc = " Wrap header preample when editing a draft in an editor. This allows you"] # [doc = " to write non-plain text email without the preamble creating syntax"] # [doc = " errors. They are stripped when you return from the editor. The"] # [doc = " values should be a two element array of strings, a prefix and suffix."] # [doc = " Default: None"] # [serde (alias = "wrap-header-preample")] # [serde (default)] pub wrap_header_preamble : Option < Option < (String , String) > > , # [doc = " Store sent mail after successful submission. This setting is meant to be"] # [doc = " disabled for non-standard behaviour in gmail, which auto-saves sent"] # [doc = " mail on its own. Default: true"] # [serde (default)] pub store_sent_mail : Option < bool > , # [doc = " The attribution line appears above the quoted reply text."] # [doc = " The format specifiers for the replied address are:"] # [doc = " - `%+f` — the sender's name and email address."] # [doc = " - `%+n` — the sender's name (or email address, if no name is included)."] # [doc = " - `%+a` — the sender's email address."] # [doc = " The format string is passed to strftime(3) with the replied envelope's"] # [doc = " date. Default: \"On %a, %0e %b %Y %H:%M, %+f wrote:%n\""] # [serde (default)] pub attribution_format_string : Option < Option < String > > , # [doc = " Whether the strftime call for the attribution string uses the POSIX"] # [doc = " locale instead of the user's active locale"] # [doc = " Default: true"] # [serde (default)] pub attribution_use_posix_locale : Option < bool > , # [doc = " Forward emails as attachment? (Alternative is inline)"] # [doc = " Default: ask"] # [serde (alias = "forward-as-attachment")] # [serde (default)] pub forward_as_attachment : Option < ToggleFlag > , # [doc = " Alternative lists of reply prefixes (etc. [\"Re:\", \"RE:\", ...]) to strip"] # [doc = " Default: `[\"Re:\", \"RE:\", \"Fwd:\", \"Fw:\", \"回复:\", \"回覆:\", \"SV:\", \"Sv:\","] # [doc = " \"VS:\", \"Antw:\", \"Doorst:\", \"VS:\", \"VL:\", \"REF:\", \"TR:\", \"TR:\", \"AW:\","] # [doc = " \"WG:\", \"ΑΠ:\", \"Απ:\", \"απ:\", \"ΠΡΘ:\", \"Πρθ:\", \"πρθ:\", \"ΣΧΕΤ:\", \"Σχετ:\","] # [doc = " \"σχετ:\", \"ΠΡΘ:\", \"Πρθ:\", \"πρθ:\", \"Vá:\", \"Továbbítás:\", \"R:\", \"I:\","] # [doc = " \"RIF:\", \"FS:\", \"BLS:\", \"TRS:\", \"VS:\", \"VB:\", \"RV:\", \"RES:\", \"Res\","] # [doc = " \"ENC:\", \"Odp:\", \"PD:\", \"YNT:\", \"İLT:\", \"ATB:\", \"YML:\"]`"] # [serde (alias = "reply-prefix-list-to-strip")] # [serde (default)] pub reply_prefix_list_to_strip : Option < Option < Vec < String > > > , # [doc = " The prefix to use in reply subjects. The de facto prefix is \"Re:\"."] # [serde (alias = "reply-prefix")] # [serde (default)] pub reply_prefix : Option < String > , # [doc = " Custom `compose-hooks`."] # [serde (alias = "custom-compose-hooks")] # [serde (default)] pub custom_compose_hooks : Option < Vec < ComposeHook > > , # [doc = " Disabled `compose-hooks`."] # [serde (alias = "disabled-compose-hooks")] # [serde (default)] pub disabled_compose_hooks : Option < Vec < String > > } impl Default for ComposingSettingsOverride { fn default () -> Self { ComposingSettingsOverride { send_mail : None , editor_command : None , embedded_pty : None , format_flowed : None , insert_user_agent : None , default_header_values : None , wrap_header_preamble : None , store_sent_mail : None , attribution_format_string : None , attribution_use_posix_locale : None , forward_as_attachment : None , reply_prefix_list_to_strip : None , reply_prefix : None , custom_compose_hooks : None , disabled_compose_hooks : None } } }
|
||||
# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct ComposingSettingsOverride { # [doc = " A command to pipe new emails to"] # [doc = " Required"] # [serde (default)] pub send_mail : Option < SendMail > , # [doc = " Command to launch editor. Can have arguments. Draft filename is given as"] # [doc = " the last argument. If it's missing, the environment variable $EDITOR is"] # [doc = " looked up."] # [serde (alias = "editor-command" , alias = "editor-cmd" , alias = "editor_cmd")] # [serde (default)] pub editor_command : Option < Option < String > > , # [doc = " Embedded editor (for terminal interfaces) instead of forking and"] # [doc = " waiting."] # [serde (alias = "embed")] # [serde (default)] pub embedded_pty : Option < bool > , # [doc = " Set \"format=flowed\" in plain text attachments."] # [doc = " Default: true"] # [serde (alias = "format-flowed")] # [serde (default)] pub format_flowed : Option < bool > , # [doc = " Set User-Agent"] # [doc = " Default: empty"] # [serde (alias = "insert_user_agent")] # [serde (default)] pub insert_user_agent : Option < bool > , # [doc = " Set default header values for new drafts"] # [doc = " Default: empty"] # [serde (alias = "default-header-values")] # [serde (default)] pub default_header_values : Option < HashMap < HeaderName , String > > , # [doc = " Wrap header preample when editing a draft in an editor. This allows you"] # [doc = " to write non-plain text email without the preamble creating syntax"] # [doc = " errors. They are stripped when you return from the editor. The"] # [doc = " values should be a two element array of strings, a prefix and suffix."] # [doc = " Default: None"] # [serde (alias = "wrap-header-preample")] # [serde (default)] pub wrap_header_preamble : Option < Option < (String , String) > > , # [doc = " Store sent mail after successful submission. This setting is meant to be"] # [doc = " disabled for non-standard behaviour in gmail, which auto-saves sent"] # [doc = " mail on its own. Default: true"] # [serde (default)] pub store_sent_mail : Option < bool > , # [doc = " The attribution line appears above the quoted reply text."] # [doc = " The format specifiers for the replied address are:"] # [doc = " - `%+f` — the sender's name and email address."] # [doc = " - `%+n` — the sender's name (or email address, if no name is included)."] # [doc = " - `%+a` — the sender's email address."] # [doc = " The format string is passed to strftime(3) with the replied envelope's"] # [doc = " date. Default: \"On %a, %0e %b %Y %H:%M, %+f wrote:%n\""] # [serde (default)] pub attribution_format_string : Option < Option < String > > , # [doc = " Whether the strftime call for the attribution string uses the POSIX"] # [doc = " locale instead of the user's active locale"] # [doc = " Default: true"] # [serde (default)] pub attribution_use_posix_locale : Option < bool > , # [doc = " Forward emails as attachment? (Alternative is inline)"] # [doc = " Default: ask"] # [serde (alias = "forward-as-attachment")] # [serde (default)] pub forward_as_attachment : Option < ToggleFlag > , # [doc = " Alternative lists of reply prefixes (etc. [\"Re:\", \"RE:\", ...]) to strip"] # [doc = " Default: `[\"Re:\", \"RE:\", \"Fwd:\", \"Fw:\", \"回复:\", \"回覆:\", \"SV:\", \"Sv:\","] # [doc = " \"VS:\", \"Antw:\", \"Doorst:\", \"VS:\", \"VL:\", \"REF:\", \"TR:\", \"TR:\", \"AW:\","] # [doc = " \"WG:\", \"ΑΠ:\", \"Απ:\", \"απ:\", \"ΠΡΘ:\", \"Πρθ:\", \"πρθ:\", \"ΣΧΕΤ:\", \"Σχετ:\","] # [doc = " \"σχετ:\", \"ΠΡΘ:\", \"Πρθ:\", \"πρθ:\", \"Vá:\", \"Továbbítás:\", \"R:\", \"I:\","] # [doc = " \"RIF:\", \"FS:\", \"BLS:\", \"TRS:\", \"VS:\", \"VB:\", \"RV:\", \"RES:\", \"Res\","] # [doc = " \"ENC:\", \"Odp:\", \"PD:\", \"YNT:\", \"İLT:\", \"ATB:\", \"YML:\"]`"] # [serde (alias = "reply-prefix-list-to-strip")] # [serde (default)] pub reply_prefix_list_to_strip : Option < Option < Vec < String > > > , # [doc = " The prefix to use in reply subjects. The de facto prefix is \"Re:\"."] # [serde (alias = "reply-prefix")] # [serde (default)] pub reply_prefix : Option < String > , # [doc = " Custom `compose-hooks`."] # [serde (alias = "custom-compose-hooks")] # [serde (default)] pub custom_compose_hooks : Option < Vec < ComposeHook > > , # [doc = " Disabled `compose-hooks`."] # [serde (alias = "disabled-compose-hooks")] # [serde (default)] pub disabled_compose_hooks : Option < Vec < String > > } impl Default for ComposingSettingsOverride { fn default () -> Self { Self { send_mail : None , editor_command : None , embedded_pty : None , format_flowed : None , insert_user_agent : None , default_header_values : None , wrap_header_preamble : None , store_sent_mail : None , attribution_format_string : None , attribution_use_posix_locale : None , forward_as_attachment : None , reply_prefix_list_to_strip : None , reply_prefix : None , custom_compose_hooks : None , disabled_compose_hooks : None } } }
|
||||
|
||||
# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct TagsSettingsOverride { # [serde (deserialize_with = "tag_color_de")] # [serde (default)] pub colors : Option < HashMap < TagHash , Color > > , # [serde (deserialize_with = "tag_set_de" , alias = "ignore-tags")] # [serde (default)] pub ignore_tags : Option < HashSet < TagHash > > } impl Default for TagsSettingsOverride { fn default () -> Self { TagsSettingsOverride { colors : None , ignore_tags : None } } }
|
||||
# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct TagsSettingsOverride { # [serde (deserialize_with = "tag_color_de")] # [serde (default)] pub colors : Option < HashMap < TagHash , Color > > , # [serde (deserialize_with = "tag_set_de" , alias = "ignore-tags")] # [serde (default)] pub ignore_tags : Option < HashSet < TagHash > > } impl Default for TagsSettingsOverride { fn default () -> Self { Self { colors : None , ignore_tags : None } } }
|
||||
|
||||
# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct PGPSettingsOverride { # [doc = " auto verify signed e-mail according to RFC3156"] # [doc = " Default: true"] # [serde (alias = "auto-verify-signatures")] # [serde (default)] pub auto_verify_signatures : Option < bool > , # [doc = " auto decrypt encrypted e-mail"] # [doc = " Default: true"] # [serde (alias = "auto-decrypt")] # [serde (default)] pub auto_decrypt : Option < bool > , # [doc = " always sign sent e-mail"] # [doc = " Default: false"] # [serde (alias = "auto-sign")] # [serde (default)] pub auto_sign : Option < bool > , # [doc = " Auto encrypt sent e-mail"] # [doc = " Default: false"] # [serde (alias = "auto-encrypt")] # [serde (default)] pub auto_encrypt : Option < bool > , # [doc = " Default: None"] # [serde (alias = "sign-key")] # [serde (default)] pub sign_key : Option < Option < String > > , # [doc = " Default: None"] # [serde (alias = "decrypt-key")] # [serde (default)] pub decrypt_key : Option < Option < String > > , # [doc = " Default: None"] # [serde (alias = "encrypt-key")] # [serde (default)] pub encrypt_key : Option < Option < String > > , # [doc = " Allow remote lookups"] # [doc = " Default: None"] # [serde (alias = "allow-remote-lookups")] # [serde (default)] pub allow_remote_lookup : Option < ToggleFlag > , # [doc = " Remote lookup mechanisms."] # [doc = " Default: \"local,wkd\""] # [cfg_attr (feature = "gpgme" , serde (alias = "remote-lookup-mechanisms"))] # [cfg (feature = "gpgme")] # [serde (default)] pub remote_lookup_mechanisms : Option < melib :: gpgme :: LocateKey > , # [cfg (not (feature = "gpgme"))] # [cfg_attr (not (feature = "gpgme") , serde (alias = "remote-lookup-mechanisms"))] # [serde (default)] pub remote_lookup_mechanisms : Option < String > } impl Default for PGPSettingsOverride { fn default () -> Self { PGPSettingsOverride { auto_verify_signatures : None , auto_decrypt : None , auto_sign : None , auto_encrypt : None , sign_key : None , decrypt_key : None , encrypt_key : None , allow_remote_lookup : None , remote_lookup_mechanisms : None } } }
|
||||
# [derive (Debug , Serialize , Deserialize , Clone)] # [serde (deny_unknown_fields)] pub struct PGPSettingsOverride { # [doc = " auto verify signed e-mail according to RFC3156"] # [doc = " Default: true"] # [serde (alias = "auto-verify-signatures")] # [serde (default)] pub auto_verify_signatures : Option < bool > , # [doc = " auto decrypt encrypted e-mail"] # [doc = " Default: true"] # [serde (alias = "auto-decrypt")] # [serde (default)] pub auto_decrypt : Option < bool > , # [doc = " always sign sent e-mail"] # [doc = " Default: false"] # [serde (alias = "auto-sign")] # [serde (default)] pub auto_sign : Option < bool > , # [doc = " Auto encrypt sent e-mail"] # [doc = " Default: false"] # [serde (alias = "auto-encrypt")] # [serde (default)] pub auto_encrypt : Option < bool > , # [doc = " Default: None"] # [serde (alias = "sign-key")] # [serde (default)] pub sign_key : Option < Option < String > > , # [doc = " Default: None"] # [serde (alias = "decrypt-key")] # [serde (default)] pub decrypt_key : Option < Option < String > > , # [doc = " Default: None"] # [serde (alias = "encrypt-key")] # [serde (default)] pub encrypt_key : Option < Option < String > > , # [doc = " Allow remote lookups"] # [doc = " Default: None"] # [serde (alias = "allow-remote-lookups")] # [serde (default)] pub allow_remote_lookup : Option < ToggleFlag > , # [doc = " Remote lookup mechanisms."] # [doc = " Default: \"local,wkd\""] # [cfg_attr (feature = "gpgme" , serde (alias = "remote-lookup-mechanisms"))] # [cfg (feature = "gpgme")] # [serde (default)] pub remote_lookup_mechanisms : Option < melib :: gpgme :: LocateKey > , # [cfg (not (feature = "gpgme"))] # [cfg_attr (not (feature = "gpgme") , serde (alias = "remote-lookup-mechanisms"))] # [serde (default)] pub remote_lookup_mechanisms : Option < String > } impl Default for PGPSettingsOverride { fn default () -> Self { Self { auto_verify_signatures : None , auto_decrypt : None , auto_sign : None , auto_encrypt : None , sign_key : None , decrypt_key : None , encrypt_key : None , allow_remote_lookup : None , remote_lookup_mechanisms : None } } }
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ fn default_lookup_mechanism() -> melib::gpgme::LocateKey {
|
|||
|
||||
impl Default for PGPSettings {
|
||||
fn default() -> Self {
|
||||
PGPSettings {
|
||||
Self {
|
||||
auto_verify_signatures: true,
|
||||
auto_decrypt: true,
|
||||
auto_sign: false,
|
||||
|
|
|
@ -55,7 +55,7 @@ pub struct TerminalSettings {
|
|||
|
||||
impl Default for TerminalSettings {
|
||||
fn default() -> Self {
|
||||
TerminalSettings {
|
||||
Self {
|
||||
theme: "dark".to_string(),
|
||||
themes: Themes::default(),
|
||||
ascii_drawing: false,
|
||||
|
|
|
@ -387,37 +387,37 @@ enum ThemeValue<T: ThemeLink> {
|
|||
|
||||
impl From<&'static str> for ThemeValue<Color> {
|
||||
fn from(from: &'static str) -> Self {
|
||||
ThemeValue::Link(from.into(), ColorField::LikeSelf)
|
||||
Self::Link(from.into(), ColorField::LikeSelf)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&'static str> for ThemeValue<Attr> {
|
||||
fn from(from: &'static str) -> Self {
|
||||
ThemeValue::Link(from.into(), ())
|
||||
Self::Link(from.into(), ())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Color> for ThemeValue<Color> {
|
||||
fn from(from: Color) -> Self {
|
||||
ThemeValue::Value(from)
|
||||
Self::Value(from)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Attr> for ThemeValue<Attr> {
|
||||
fn from(from: Attr) -> Self {
|
||||
ThemeValue::Value(from)
|
||||
Self::Value(from)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ThemeValue<Color> {
|
||||
fn default() -> Self {
|
||||
ThemeValue::Value(Color::Default)
|
||||
Self::Value(Color::Default)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ThemeValue<Attr> {
|
||||
fn default() -> Self {
|
||||
ThemeValue::Value(Attr::DEFAULT)
|
||||
Self::Value(Attr::DEFAULT)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -428,11 +428,11 @@ impl<'de> Deserialize<'de> for ThemeValue<Attr> {
|
|||
{
|
||||
if let Ok(s) = <String>::deserialize(deserializer) {
|
||||
if let Some(stripped) = s.strip_prefix('$') {
|
||||
Ok(ThemeValue::Alias(stripped.to_string().into()))
|
||||
Ok(Self::Alias(stripped.to_string().into()))
|
||||
} else if let Ok(c) = Attr::from_string_de::<'de, D, String>(s.clone()) {
|
||||
Ok(ThemeValue::Value(c))
|
||||
Ok(Self::Value(c))
|
||||
} else {
|
||||
Ok(ThemeValue::Link(s.into(), ()))
|
||||
Ok(Self::Link(s.into(), ()))
|
||||
}
|
||||
} else {
|
||||
Err(de::Error::custom("invalid theme attribute value"))
|
||||
|
@ -446,9 +446,9 @@ impl Serialize for ThemeValue<Attr> {
|
|||
S: Serializer,
|
||||
{
|
||||
match self {
|
||||
ThemeValue::Value(s) => s.serialize(serializer),
|
||||
ThemeValue::Alias(s) => format!("${}", s).serialize(serializer),
|
||||
ThemeValue::Link(s, ()) => serializer.serialize_str(s.as_ref()),
|
||||
Self::Value(s) => s.serialize(serializer),
|
||||
Self::Alias(s) => format!("${}", s).serialize(serializer),
|
||||
Self::Link(s, ()) => serializer.serialize_str(s.as_ref()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -459,15 +459,11 @@ impl Serialize for ThemeValue<Color> {
|
|||
S: Serializer,
|
||||
{
|
||||
match self {
|
||||
ThemeValue::Value(s) => s.serialize(serializer),
|
||||
ThemeValue::Alias(s) => format!("${}", s).serialize(serializer),
|
||||
ThemeValue::Link(s, ColorField::LikeSelf) => serializer.serialize_str(s.as_ref()),
|
||||
ThemeValue::Link(s, ColorField::Fg) => {
|
||||
serializer.serialize_str(format!("{}.fg", s).as_ref())
|
||||
}
|
||||
ThemeValue::Link(s, ColorField::Bg) => {
|
||||
serializer.serialize_str(format!("{}.bg", s).as_ref())
|
||||
}
|
||||
Self::Value(s) => s.serialize(serializer),
|
||||
Self::Alias(s) => format!("${}", s).serialize(serializer),
|
||||
Self::Link(s, ColorField::LikeSelf) => serializer.serialize_str(s.as_ref()),
|
||||
Self::Link(s, ColorField::Fg) => serializer.serialize_str(format!("{}.fg", s).as_ref()),
|
||||
Self::Link(s, ColorField::Bg) => serializer.serialize_str(format!("{}.bg", s).as_ref()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -479,21 +475,21 @@ impl<'de> Deserialize<'de> for ThemeValue<Color> {
|
|||
{
|
||||
if let Ok(s) = <String>::deserialize(deserializer) {
|
||||
if let Some(stripped) = s.strip_prefix('$') {
|
||||
Ok(ThemeValue::Alias(stripped.to_string().into()))
|
||||
Ok(Self::Alias(stripped.to_string().into()))
|
||||
} else if let Ok(c) = Color::from_string_de::<'de, D>(s.clone()) {
|
||||
Ok(ThemeValue::Value(c))
|
||||
Ok(Self::Value(c))
|
||||
} else if s.ends_with(".fg") {
|
||||
Ok(ThemeValue::Link(
|
||||
Ok(Self::Link(
|
||||
s[..s.len() - 3].to_string().into(),
|
||||
ColorField::Fg,
|
||||
))
|
||||
} else if s.ends_with(".bg") {
|
||||
Ok(ThemeValue::Link(
|
||||
Ok(Self::Link(
|
||||
s[..s.len() - 3].to_string().into(),
|
||||
ColorField::Bg,
|
||||
))
|
||||
} else {
|
||||
Ok(ThemeValue::Link(s.into(), ColorField::LikeSelf))
|
||||
Ok(Self::Link(s.into(), ColorField::LikeSelf))
|
||||
}
|
||||
} else {
|
||||
Err(de::Error::custom("invalid theme color value"))
|
||||
|
@ -569,7 +565,7 @@ mod regexp {
|
|||
impl Eq for RegexpWrapper {}
|
||||
|
||||
impl PartialEq for RegexpWrapper {
|
||||
fn eq(&self, other: &RegexpWrapper) -> bool {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.0.as_str().eq(other.0.as_str())
|
||||
}
|
||||
}
|
||||
|
@ -827,7 +823,7 @@ impl<'de> Deserialize<'de> for Themes {
|
|||
attrs: Option<ThemeValue<Attr>>,
|
||||
}
|
||||
|
||||
let mut ret = Themes::default();
|
||||
let mut ret = Self::default();
|
||||
let mut s = <ThemesOptions>::deserialize(deserializer)?;
|
||||
for tk in s.other_themes.keys() {
|
||||
ret.other_themes.insert(tk.clone(), ret.dark.clone());
|
||||
|
@ -1217,10 +1213,10 @@ impl Themes {
|
|||
}
|
||||
pub fn validate(&self) -> Result<()> {
|
||||
let hash_set: HashSet<&'static str> = DEFAULT_KEYS.iter().copied().collect();
|
||||
Themes::validate_keys("light", &self.light, &hash_set)?;
|
||||
Themes::validate_keys("dark", &self.dark, &hash_set)?;
|
||||
Self::validate_keys("light", &self.light, &hash_set)?;
|
||||
Self::validate_keys("dark", &self.dark, &hash_set)?;
|
||||
for (name, t) in self.other_themes.iter() {
|
||||
Themes::validate_keys(name, t, &hash_set)?;
|
||||
Self::validate_keys(name, t, &hash_set)?;
|
||||
}
|
||||
if let Err(err) = is_cyclic(&self.light) {
|
||||
return Err(Error::new(format!("light theme contains a cycle: {}", err)));
|
||||
|
@ -1288,7 +1284,7 @@ impl std::fmt::Display for Themes {
|
|||
|
||||
impl Default for Themes {
|
||||
#[allow(clippy::needless_update)]
|
||||
fn default() -> Themes {
|
||||
fn default() -> Self {
|
||||
let mut light = IndexMap::default();
|
||||
let mut dark = IndexMap::default();
|
||||
let other_themes = IndexMap::default();
|
||||
|
@ -1734,7 +1730,7 @@ impl Default for Themes {
|
|||
|
||||
add!("pager.highlight_search", light = { fg: Color::White, bg: Color::Byte(6) /* Teal */, attrs: Attr::BOLD }, dark = { fg: Color::White, bg: Color::Byte(6) /* Teal */, attrs: Attr::BOLD });
|
||||
add!("pager.highlight_search_current", light = { fg: Color::White, bg: Color::Byte(17) /* NavyBlue */, attrs: Attr::BOLD }, dark = { fg: Color::White, bg: Color::Byte(17) /* NavyBlue */, attrs: Attr::BOLD });
|
||||
Themes {
|
||||
Self {
|
||||
light: Theme {
|
||||
keys: light,
|
||||
attr_aliases: Default::default(),
|
||||
|
@ -2085,7 +2081,7 @@ fn is_cyclic(theme: &Theme) -> std::result::Result<(), String> {
|
|||
fn test_theme_parsing() {
|
||||
/* MUST SUCCEED: default themes should be valid */
|
||||
let def = Themes::default();
|
||||
assert!(def.validate().is_ok());
|
||||
def.validate().unwrap();
|
||||
/* MUST SUCCEED: new user theme `hunter2`, theme `dark` has user
|
||||
* redefinitions */
|
||||
const TEST_STR: &str = r#"[dark]
|
||||
|
@ -2121,27 +2117,27 @@ fn test_theme_parsing() {
|
|||
),
|
||||
Color::Byte(15), // White
|
||||
);
|
||||
assert!(parsed.validate().is_ok());
|
||||
parsed.validate().unwrap();
|
||||
/* MUST FAIL: theme `dark` contains a cycle */
|
||||
const HAS_CYCLE: &str = r#"[dark]
|
||||
"mail.listing.compact.even" = { fg = "mail.listing.compact.odd" }
|
||||
"mail.listing.compact.odd" = { fg = "mail.listing.compact.even" }
|
||||
"#;
|
||||
let parsed: Themes = toml::from_str(HAS_CYCLE).unwrap();
|
||||
assert!(parsed.validate().is_err());
|
||||
parsed.validate().unwrap_err();
|
||||
/* MUST FAIL: theme `dark` contains an invalid key */
|
||||
const HAS_INVALID_KEYS: &str = r#"[dark]
|
||||
"asdfsafsa" = { fg = "Black" }
|
||||
"#;
|
||||
let parsed: std::result::Result<Themes, _> = toml::from_str(HAS_INVALID_KEYS);
|
||||
assert!(parsed.is_err());
|
||||
parsed.unwrap_err();
|
||||
/* MUST SUCCEED: alias $Jebediah resolves to a valid color */
|
||||
const TEST_ALIAS_STR: &str = r##"[dark]
|
||||
color_aliases= { "Jebediah" = "#b4da55" }
|
||||
"mail.listing.tag_default" = { fg = "$Jebediah" }
|
||||
"##;
|
||||
let parsed: Themes = toml::from_str(TEST_ALIAS_STR).unwrap();
|
||||
assert!(parsed.validate().is_ok());
|
||||
parsed.validate().unwrap();
|
||||
assert_eq!(
|
||||
unlink_fg(
|
||||
&parsed.dark,
|
||||
|
@ -2156,42 +2152,42 @@ color_aliases= { "Jebediah" = "#b4da55" }
|
|||
"mail.listing.tag_default" = { fg = "$Jebedia" }
|
||||
"##;
|
||||
let parsed: Themes = toml::from_str(TEST_INVALID_ALIAS_STR).unwrap();
|
||||
assert!(parsed.validate().is_err());
|
||||
parsed.validate().unwrap_err();
|
||||
/* MUST FAIL: Color alias $Jebediah is defined as itself */
|
||||
const TEST_CYCLIC_ALIAS_STR: &str = r#"[dark]
|
||||
color_aliases= { "Jebediah" = "$Jebediah" }
|
||||
"mail.listing.tag_default" = { fg = "$Jebediah" }
|
||||
"#;
|
||||
let parsed: Themes = toml::from_str(TEST_CYCLIC_ALIAS_STR).unwrap();
|
||||
assert!(parsed.validate().is_err());
|
||||
parsed.validate().unwrap_err();
|
||||
/* MUST FAIL: Attr alias $Jebediah is defined as itself */
|
||||
const TEST_CYCLIC_ALIAS_ATTR_STR: &str = r#"[dark]
|
||||
attr_aliases= { "Jebediah" = "$Jebediah" }
|
||||
"mail.listing.tag_default" = { attrs = "$Jebediah" }
|
||||
"#;
|
||||
let parsed: Themes = toml::from_str(TEST_CYCLIC_ALIAS_ATTR_STR).unwrap();
|
||||
assert!(parsed.validate().is_err());
|
||||
parsed.validate().unwrap_err();
|
||||
/* MUST FAIL: alias $Jebediah resolves to a cycle */
|
||||
const TEST_CYCLIC_ALIAS_STR_2: &str = r#"[dark]
|
||||
color_aliases= { "Jebediah" = "$JebediahJr", "JebediahJr" = "mail.listing.tag_default" }
|
||||
"mail.listing.tag_default" = { fg = "$Jebediah" }
|
||||
"#;
|
||||
let parsed: Themes = toml::from_str(TEST_CYCLIC_ALIAS_STR_2).unwrap();
|
||||
assert!(parsed.validate().is_err());
|
||||
parsed.validate().unwrap_err();
|
||||
/* MUST SUCCEED: alias $Jebediah resolves to a key's field */
|
||||
const TEST_CYCLIC_ALIAS_STR_3: &str = r#"[dark]
|
||||
color_aliases= { "Jebediah" = "$JebediahJr", "JebediahJr" = "mail.listing.tag_default.bg" }
|
||||
"mail.listing.tag_default" = { fg = "$Jebediah", bg = "Black" }
|
||||
"#;
|
||||
let parsed: Themes = toml::from_str(TEST_CYCLIC_ALIAS_STR_3).unwrap();
|
||||
assert!(parsed.validate().is_ok());
|
||||
parsed.validate().unwrap();
|
||||
/* MUST FAIL: alias $Jebediah resolves to an invalid key */
|
||||
const TEST_INVALID_LINK_KEY_FIELD_STR: &str = r#"[dark]
|
||||
color_aliases= { "Jebediah" = "$JebediahJr", "JebediahJr" = "mail.listing.tag_default.attrs" }
|
||||
"mail.listing.tag_default" = { fg = "$Jebediah", bg = "Black" }
|
||||
"#;
|
||||
let parsed: Themes = toml::from_str(TEST_INVALID_LINK_KEY_FIELD_STR).unwrap();
|
||||
assert!(parsed.validate().is_err());
|
||||
parsed.validate().unwrap_err();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -59,7 +59,7 @@ impl std::fmt::Display for ContactManager {
|
|||
impl ContactManager {
|
||||
pub fn new(context: &Context) -> Self {
|
||||
let theme_default: ThemeAttribute = crate::conf::value(context, "theme_default");
|
||||
ContactManager {
|
||||
Self {
|
||||
id: ComponentId::default(),
|
||||
parent_id: None,
|
||||
card: Card::new(),
|
||||
|
@ -227,14 +227,14 @@ impl Component for ContactManager {
|
|||
}
|
||||
}
|
||||
self.set_dirty(true);
|
||||
if let UIEvent::InsertInput(_) = event {
|
||||
if matches!(event, UIEvent::InsertInput(_)) {
|
||||
self.has_changes = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
ViewMode::ReadOnly => {
|
||||
if let &mut UIEvent::Input(Key::Esc) = event {
|
||||
if matches!(event, UIEvent::Input(Key::Esc)) {
|
||||
if self.can_quit_cleanly(context) {
|
||||
self.unrealize(context);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ impl ContactList {
|
|||
index: i,
|
||||
})
|
||||
.collect();
|
||||
ContactList {
|
||||
Self {
|
||||
accounts,
|
||||
cursor_pos: 0,
|
||||
new_cursor_pos: 0,
|
||||
|
@ -112,13 +112,13 @@ impl ContactList {
|
|||
}
|
||||
|
||||
pub fn for_account(pos: usize, context: &Context) -> Self {
|
||||
ContactList {
|
||||
Self {
|
||||
account_pos: pos,
|
||||
..Self::new(context)
|
||||
}
|
||||
}
|
||||
|
||||
fn initialize(&mut self, context: &mut Context) {
|
||||
fn initialize(&mut self, context: &Context) {
|
||||
self.data_columns.clear();
|
||||
let account = &context.accounts[self.account_pos];
|
||||
let book = &account.address_book;
|
||||
|
@ -274,7 +274,7 @@ impl ContactList {
|
|||
grid: &mut CellBuffer,
|
||||
area: Area,
|
||||
a: &AccountMenuEntry,
|
||||
context: &mut Context,
|
||||
context: &Context,
|
||||
) {
|
||||
let width = area.width();
|
||||
let must_highlight_account: bool = self.account_pos == a.index;
|
||||
|
|
|
@ -176,7 +176,7 @@ impl JobExecutor {
|
|||
/// A queue that holds scheduled tasks.
|
||||
pub fn new(sender: Sender<ThreadEvent>) -> Self {
|
||||
// Create a queue.
|
||||
let mut ret = JobExecutor {
|
||||
let mut ret = Self {
|
||||
global_queue: Arc::new(Injector::new()),
|
||||
workers: vec![],
|
||||
parkers: vec![],
|
||||
|
@ -306,7 +306,7 @@ impl JobExecutor {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn create_timer(self: Arc<JobExecutor>, interval: Duration, value: Duration) -> Timer {
|
||||
pub fn create_timer(self: Arc<Self>, interval: Duration, value: Duration) -> Timer {
|
||||
let timer = TimerPrivate {
|
||||
interval,
|
||||
cancel: Arc::new(Mutex::new(false)),
|
||||
|
|
|
@ -110,7 +110,7 @@ impl JobManager {
|
|||
}
|
||||
}
|
||||
|
||||
fn initialize(&mut self, context: &mut Context) {
|
||||
fn initialize(&mut self, context: &Context) {
|
||||
self.set_dirty(true);
|
||||
|
||||
let mut entries = (*context.main_loop_handler.job_executor.jobs.lock().unwrap()).clone();
|
||||
|
|
|
@ -19,7 +19,47 @@
|
|||
* along with meli. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#![deny(rustdoc::redundant_explicit_links)]
|
||||
#![deny(
|
||||
rustdoc::redundant_explicit_links,
|
||||
/* groups */
|
||||
clippy::correctness,
|
||||
clippy::suspicious,
|
||||
clippy::complexity,
|
||||
clippy::perf,
|
||||
clippy::cargo,
|
||||
clippy::nursery,
|
||||
clippy::style,
|
||||
/* restriction */
|
||||
clippy::dbg_macro,
|
||||
clippy::rc_buffer,
|
||||
clippy::as_underscore,
|
||||
clippy::assertions_on_result_states,
|
||||
/* rustdoc */
|
||||
rustdoc::broken_intra_doc_links,
|
||||
/* pedantic */
|
||||
//clippy::cast_lossless,
|
||||
//clippy::cast_possible_wrap,
|
||||
//clippy::ptr_as_ptr,
|
||||
clippy::bool_to_int_with_if,
|
||||
clippy::borrow_as_ptr,
|
||||
clippy::cast_ptr_alignment,
|
||||
clippy::large_futures,
|
||||
clippy::waker_clone_wake,
|
||||
clippy::unused_enumerate_index,
|
||||
clippy::unnecessary_fallible_conversions,
|
||||
clippy::struct_field_names,
|
||||
clippy::manual_hash_one,
|
||||
clippy::into_iter_without_iter,
|
||||
)]
|
||||
#![allow(
|
||||
clippy::option_if_let_else,
|
||||
clippy::missing_const_for_fn,
|
||||
clippy::significant_drop_tightening,
|
||||
clippy::multiple_crate_versions,
|
||||
clippy::significant_drop_in_scrutinee,
|
||||
clippy::cognitive_complexity,
|
||||
clippy::manual_clamp
|
||||
)]
|
||||
|
||||
//!
|
||||
//! This crate contains the frontend stuff of the application. The application
|
||||
|
|
|
@ -134,12 +134,12 @@ enum ViewMode {
|
|||
impl ViewMode {
|
||||
#[inline]
|
||||
fn is_edit(&self) -> bool {
|
||||
matches!(self, ViewMode::Edit)
|
||||
matches!(self, Self::Edit)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_edit_attachments(&self) -> bool {
|
||||
matches!(self, ViewMode::EditAttachments { .. })
|
||||
matches!(self, Self::EditAttachments { .. })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ impl Composer {
|
|||
pager.set_show_scrollbar(true);
|
||||
let mut form = FormWidget::default();
|
||||
form.set_cursor(2);
|
||||
Composer {
|
||||
Self {
|
||||
reply_context: None,
|
||||
account_hash: AccountHash::default(),
|
||||
cursor: Cursor::Headers,
|
||||
|
@ -195,9 +195,9 @@ impl Composer {
|
|||
}
|
||||
|
||||
pub fn with_account(account_hash: AccountHash, context: &Context) -> Self {
|
||||
let mut ret = Composer {
|
||||
let mut ret = Self {
|
||||
account_hash,
|
||||
..Composer::new(context)
|
||||
..Self::new(context)
|
||||
};
|
||||
|
||||
// Add user's custom hooks.
|
||||
|
@ -248,7 +248,7 @@ impl Composer {
|
|||
bytes: &[u8],
|
||||
context: &Context,
|
||||
) -> Result<Self> {
|
||||
let mut ret = Composer::with_account(account_hash, context);
|
||||
let mut ret = Self::with_account(account_hash, context);
|
||||
// Add user's custom hooks.
|
||||
for hook in account_settings!(context[account_hash].composing.custom_compose_hooks)
|
||||
.iter()
|
||||
|
@ -273,10 +273,10 @@ impl Composer {
|
|||
pub fn reply_to(
|
||||
coordinates @ (account_hash, _, _): (AccountHash, MailboxHash, EnvelopeHash),
|
||||
reply_body: String,
|
||||
context: &mut Context,
|
||||
context: &Context,
|
||||
reply_to_all: bool,
|
||||
) -> Self {
|
||||
let mut ret = Composer::with_account(account_hash, context);
|
||||
let mut ret = Self::with_account(account_hash, context);
|
||||
// Add user's custom hooks.
|
||||
for hook in account_settings!(context[account_hash].composing.custom_compose_hooks)
|
||||
.iter()
|
||||
|
@ -451,9 +451,9 @@ impl Composer {
|
|||
pub fn reply_to_select(
|
||||
coordinates @ (account_hash, _, _): (AccountHash, MailboxHash, EnvelopeHash),
|
||||
reply_body: String,
|
||||
context: &mut Context,
|
||||
context: &Context,
|
||||
) -> Self {
|
||||
let mut ret = Composer::reply_to(coordinates, reply_body, context, false);
|
||||
let mut ret = Self::reply_to(coordinates, reply_body, context, false);
|
||||
let account = &context.accounts[&account_hash];
|
||||
let parent_message = account.collection.get_env(coordinates.2);
|
||||
/* If message is from a mailing list and we detect a List-Post header, ask
|
||||
|
@ -499,17 +499,17 @@ impl Composer {
|
|||
pub fn reply_to_author(
|
||||
coordinates: (AccountHash, MailboxHash, EnvelopeHash),
|
||||
reply_body: String,
|
||||
context: &mut Context,
|
||||
context: &Context,
|
||||
) -> Self {
|
||||
Composer::reply_to(coordinates, reply_body, context, false)
|
||||
Self::reply_to(coordinates, reply_body, context, false)
|
||||
}
|
||||
|
||||
pub fn reply_to_all(
|
||||
coordinates: (AccountHash, MailboxHash, EnvelopeHash),
|
||||
reply_body: String,
|
||||
context: &mut Context,
|
||||
context: &Context,
|
||||
) -> Self {
|
||||
Composer::reply_to(coordinates, reply_body, context, true)
|
||||
Self::reply_to(coordinates, reply_body, context, true)
|
||||
}
|
||||
|
||||
pub fn forward(
|
||||
|
@ -517,9 +517,9 @@ impl Composer {
|
|||
bytes: &[u8],
|
||||
env: &Envelope,
|
||||
as_attachment: bool,
|
||||
context: &mut Context,
|
||||
context: &Context,
|
||||
) -> Self {
|
||||
let mut composer = Composer::with_account(coordinates.0, context);
|
||||
let mut composer = Self::with_account(coordinates.0, context);
|
||||
let mut draft: Draft = Draft::default();
|
||||
draft.set_header(HeaderName::SUBJECT, format!("Fwd: {}", env.subject()));
|
||||
let preamble = format!(
|
||||
|
@ -1171,7 +1171,7 @@ impl Component for Composer {
|
|||
(ViewMode::Send(ref selector), UIEvent::FinishedUIDialog(id, result))
|
||||
if selector.id() == *id =>
|
||||
{
|
||||
if let Some(true) = result.downcast_ref::<bool>() {
|
||||
if matches!(result.downcast_ref::<bool>(), Some(true)) {
|
||||
self.update_draft();
|
||||
match send_draft_async(
|
||||
#[cfg(feature = "gpgme")]
|
||||
|
@ -1481,7 +1481,8 @@ impl Component for Composer {
|
|||
..
|
||||
} = self;
|
||||
|
||||
for err in hooks
|
||||
// Collect errors in a vector because filter_map borrows context
|
||||
let errors = hooks
|
||||
.iter_mut()
|
||||
.filter_map(|h| {
|
||||
if let Err(err) = h(context, draft) {
|
||||
|
@ -1490,8 +1491,8 @@ impl Component for Composer {
|
|||
None
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
{
|
||||
.collect::<Vec<_>>();
|
||||
for err in errors {
|
||||
context.replies.push_back(UIEvent::Notification {
|
||||
title: None,
|
||||
source: None,
|
||||
|
@ -2479,7 +2480,7 @@ pub fn save_draft(
|
|||
|
||||
pub fn send_draft_async(
|
||||
#[cfg(feature = "gpgme")] gpg_state: gpg::GpgComposeState,
|
||||
context: &mut Context,
|
||||
context: &Context,
|
||||
account_hash: AccountHash,
|
||||
mut draft: Draft,
|
||||
mailbox_type: SpecialUsageMailbox,
|
||||
|
@ -2642,7 +2643,7 @@ hello world.
|
|||
let envelope =
|
||||
Envelope::from_bytes(raw_mail.as_bytes(), None).expect("Could not parse mail");
|
||||
let tempdir = tempfile::tempdir().unwrap();
|
||||
let mut context = Context::new_mock(&tempdir);
|
||||
let context = Context::new_mock(&tempdir);
|
||||
let account_hash = context.accounts[0].hash();
|
||||
let mailbox_hash = MailboxHash::default();
|
||||
let envelope_hash = envelope.hash();
|
||||
|
@ -2652,7 +2653,7 @@ hello world.
|
|||
let composer = Composer::reply_to(
|
||||
(account_hash, mailbox_hash, envelope_hash),
|
||||
String::new(),
|
||||
&mut context,
|
||||
&context,
|
||||
false,
|
||||
);
|
||||
assert_eq!(
|
||||
|
@ -2681,7 +2682,7 @@ hello world.
|
|||
let composer = Composer::reply_to(
|
||||
(account_hash, mailbox_hash, envelope_hash),
|
||||
String::new(),
|
||||
&mut context,
|
||||
&context,
|
||||
false,
|
||||
);
|
||||
assert_eq!(
|
||||
|
|
|
@ -54,7 +54,7 @@ impl EditAttachments {
|
|||
let mut buttons = ButtonWidget::new(("Go Back".into(), FormButtonActions::Cancel));
|
||||
buttons.set_focus(true);
|
||||
buttons.set_cursor(1);
|
||||
EditAttachments {
|
||||
Self {
|
||||
account_hash,
|
||||
mode: EditAttachmentMode::Overview,
|
||||
buttons,
|
||||
|
|
|
@ -53,7 +53,7 @@ impl KeySelection {
|
|||
local: bool,
|
||||
pattern: String,
|
||||
allow_remote_lookup: ToggleFlag,
|
||||
context: &mut Context,
|
||||
context: &Context,
|
||||
) -> Result<Self> {
|
||||
use melib::gpgme::*;
|
||||
let mut ctx = Context::new()?;
|
||||
|
@ -69,7 +69,7 @@ impl KeySelection {
|
|||
.spawn_specialized("gpg::keylist".into(), job);
|
||||
let mut progress_spinner = ProgressSpinner::new(8, context);
|
||||
progress_spinner.start();
|
||||
Ok(KeySelection::LoadingKeys {
|
||||
Ok(Self::LoadingKeys {
|
||||
handle,
|
||||
secret,
|
||||
local,
|
||||
|
@ -83,11 +83,11 @@ impl KeySelection {
|
|||
impl Component for KeySelection {
|
||||
fn draw(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||
match self {
|
||||
KeySelection::LoadingKeys {
|
||||
Self::LoadingKeys {
|
||||
ref mut progress_spinner,
|
||||
..
|
||||
} => progress_spinner.draw(grid, area.center_inside((2, 2)), context),
|
||||
KeySelection::Error { ref err, .. } => {
|
||||
Self::Error { ref err, .. } => {
|
||||
let theme_default = crate::conf::value(context, "theme_default");
|
||||
grid.write_string(
|
||||
&err.to_string(),
|
||||
|
@ -98,13 +98,13 @@ impl Component for KeySelection {
|
|||
Some(0),
|
||||
);
|
||||
}
|
||||
KeySelection::Loaded { ref mut widget, .. } => widget.draw(grid, area, context),
|
||||
Self::Loaded { ref mut widget, .. } => widget.draw(grid, area, context),
|
||||
}
|
||||
}
|
||||
|
||||
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
|
||||
match self {
|
||||
KeySelection::LoadingKeys {
|
||||
Self::LoadingKeys {
|
||||
ref mut progress_spinner,
|
||||
ref mut handle,
|
||||
secret,
|
||||
|
@ -131,10 +131,10 @@ impl Component for KeySelection {
|
|||
Ok(w) => {
|
||||
*self = w;
|
||||
}
|
||||
Err(err) => *self = KeySelection::Error { err, id },
|
||||
Err(err) => *self = Self::Error { err, id },
|
||||
}
|
||||
} else if !*local && allow_remote_lookup.is_ask() {
|
||||
*self = KeySelection::Error {
|
||||
*self = Self::Error {
|
||||
err: Error::new(format!(
|
||||
"No keys found for {}, perform remote lookup?",
|
||||
pattern
|
||||
|
@ -142,12 +142,12 @@ impl Component for KeySelection {
|
|||
id,
|
||||
}
|
||||
} else {
|
||||
*self = KeySelection::Error {
|
||||
*self = Self::Error {
|
||||
err: Error::new(format!("No keys found for {}.", pattern)),
|
||||
id,
|
||||
}
|
||||
}
|
||||
if let KeySelection::Error { ref err, .. } = self {
|
||||
if let Self::Error { ref err, .. } = self {
|
||||
context.replies.push_back(UIEvent::StatusEvent(
|
||||
StatusEvent::DisplayMessage(err.to_string()),
|
||||
));
|
||||
|
@ -184,10 +184,10 @@ impl Component for KeySelection {
|
|||
context,
|
||||
));
|
||||
widget.set_dirty(true);
|
||||
*self = KeySelection::Loaded { widget, keys };
|
||||
*self = Self::Loaded { widget, keys };
|
||||
}
|
||||
Ok(Some(Err(err))) => {
|
||||
*self = KeySelection::Error {
|
||||
*self = Self::Error {
|
||||
err,
|
||||
id: ComponentId::default(),
|
||||
};
|
||||
|
@ -197,30 +197,30 @@ impl Component for KeySelection {
|
|||
}
|
||||
_ => progress_spinner.process_event(event, context),
|
||||
},
|
||||
KeySelection::Error { .. } => false,
|
||||
KeySelection::Loaded { ref mut widget, .. } => widget.process_event(event, context),
|
||||
Self::Error { .. } => false,
|
||||
Self::Loaded { ref mut widget, .. } => widget.process_event(event, context),
|
||||
}
|
||||
}
|
||||
|
||||
fn is_dirty(&self) -> bool {
|
||||
match self {
|
||||
KeySelection::LoadingKeys {
|
||||
Self::LoadingKeys {
|
||||
ref progress_spinner,
|
||||
..
|
||||
} => progress_spinner.is_dirty(),
|
||||
KeySelection::Error { .. } => true,
|
||||
KeySelection::Loaded { ref widget, .. } => widget.is_dirty(),
|
||||
Self::Error { .. } => true,
|
||||
Self::Loaded { ref widget, .. } => widget.is_dirty(),
|
||||
}
|
||||
}
|
||||
|
||||
fn set_dirty(&mut self, value: bool) {
|
||||
match self {
|
||||
KeySelection::LoadingKeys {
|
||||
Self::LoadingKeys {
|
||||
ref mut progress_spinner,
|
||||
..
|
||||
} => progress_spinner.set_dirty(value),
|
||||
KeySelection::Error { .. } => {}
|
||||
KeySelection::Loaded { ref mut widget, .. } => widget.set_dirty(value),
|
||||
Self::Error { .. } => {}
|
||||
Self::Loaded { ref mut widget, .. } => widget.set_dirty(value),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -228,21 +228,19 @@ impl Component for KeySelection {
|
|||
|
||||
fn shortcuts(&self, context: &Context) -> ShortcutMaps {
|
||||
match self {
|
||||
KeySelection::LoadingKeys { .. } | KeySelection::Error { .. } => {
|
||||
ShortcutMaps::default()
|
||||
}
|
||||
KeySelection::Loaded { ref widget, .. } => widget.shortcuts(context),
|
||||
Self::LoadingKeys { .. } | Self::Error { .. } => ShortcutMaps::default(),
|
||||
Self::Loaded { ref widget, .. } => widget.shortcuts(context),
|
||||
}
|
||||
}
|
||||
|
||||
fn id(&self) -> ComponentId {
|
||||
match self {
|
||||
KeySelection::LoadingKeys {
|
||||
Self::LoadingKeys {
|
||||
ref progress_spinner,
|
||||
..
|
||||
} => progress_spinner.id(),
|
||||
KeySelection::Error { ref id, .. } => *id,
|
||||
KeySelection::Loaded { ref widget, .. } => widget.id(),
|
||||
Self::Error { ref id, .. } => *id,
|
||||
Self::Loaded { ref widget, .. } => widget.id(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +256,7 @@ pub struct GpgComposeState {
|
|||
|
||||
impl Default for GpgComposeState {
|
||||
fn default() -> Self {
|
||||
GpgComposeState {
|
||||
Self {
|
||||
sign_mail: ToggleFlag::Unset,
|
||||
encrypt_mail: ToggleFlag::Unset,
|
||||
encrypt_keys: vec![],
|
||||
|
|
|
@ -526,7 +526,7 @@ pub trait MailListingTrait: ListingTrait {
|
|||
match a {
|
||||
ListingAction::SetSeen => {
|
||||
if let Err(err) = account.set_flags(
|
||||
env_hashes.clone(),
|
||||
env_hashes,
|
||||
mailbox_hash,
|
||||
smallvec::smallvec![FlagOp::Set(Flag::SEEN)],
|
||||
) {
|
||||
|
@ -537,7 +537,7 @@ pub trait MailListingTrait: ListingTrait {
|
|||
}
|
||||
ListingAction::SetUnseen => {
|
||||
if let Err(err) = account.set_flags(
|
||||
env_hashes.clone(),
|
||||
env_hashes,
|
||||
mailbox_hash,
|
||||
smallvec::smallvec![FlagOp::UnSet(Flag::SEEN)],
|
||||
) {
|
||||
|
@ -548,7 +548,7 @@ pub trait MailListingTrait: ListingTrait {
|
|||
}
|
||||
ListingAction::Tag(TagAction::Add(ref tag_str)) => {
|
||||
if let Err(err) = account.set_flags(
|
||||
env_hashes.clone(),
|
||||
env_hashes,
|
||||
mailbox_hash,
|
||||
smallvec::smallvec![FlagOp::SetTag(tag_str.into())],
|
||||
) {
|
||||
|
@ -559,7 +559,7 @@ pub trait MailListingTrait: ListingTrait {
|
|||
}
|
||||
ListingAction::Tag(TagAction::Remove(ref tag_str)) => {
|
||||
if let Err(err) = account.set_flags(
|
||||
env_hashes.clone(),
|
||||
env_hashes,
|
||||
mailbox_hash,
|
||||
smallvec::smallvec![FlagOp::UnSetTag(tag_str.into())],
|
||||
) {
|
||||
|
@ -972,11 +972,11 @@ enum MenuEntryCursor {
|
|||
}
|
||||
|
||||
impl std::ops::Sub<MenuEntryCursor> for isize {
|
||||
type Output = isize;
|
||||
type Output = Self;
|
||||
|
||||
fn sub(self, other: MenuEntryCursor) -> isize {
|
||||
fn sub(self, other: MenuEntryCursor) -> Self {
|
||||
if let MenuEntryCursor::Mailbox(v) = other {
|
||||
v as isize - self
|
||||
v as Self - self
|
||||
} else {
|
||||
self - 1
|
||||
}
|
||||
|
@ -2497,7 +2497,7 @@ impl Listing {
|
|||
})
|
||||
.collect();
|
||||
let first_account_hash = account_entries[0].hash;
|
||||
let mut ret = Listing {
|
||||
let mut ret = Self {
|
||||
component: Offline(OfflineListing::new((
|
||||
first_account_hash,
|
||||
MailboxHash::default(),
|
||||
|
@ -2635,7 +2635,7 @@ impl Listing {
|
|||
}
|
||||
|
||||
/// Print a single account in the menu area.
|
||||
fn print_account(&mut self, mut area: Area, aidx: usize, context: &mut Context) -> usize {
|
||||
fn print_account(&mut self, mut area: Area, aidx: usize, context: &Context) -> usize {
|
||||
let account_y = self.menu.area().height() - area.height();
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct Line {
|
||||
|
|
|
@ -899,7 +899,7 @@ impl std::fmt::Display for CompactListing {
|
|||
|
||||
impl CompactListing {
|
||||
pub fn new(parent: ComponentId, coordinates: (AccountHash, MailboxHash)) -> Box<Self> {
|
||||
Box::new(CompactListing {
|
||||
Box::new(Self {
|
||||
cursor_pos: (AccountHash::default(), MailboxHash::default(), 0),
|
||||
new_cursor_pos: (coordinates.0, coordinates.1, 0),
|
||||
length: 0,
|
||||
|
|
|
@ -793,7 +793,7 @@ impl ConversationsListing {
|
|||
if thread.has_attachments() { "📎" } else { "" },
|
||||
if thread.snoozed() { "💤" } else { "" }
|
||||
)),
|
||||
from: FromString(Address::display_name_slice(from).to_string()),
|
||||
from: FromString(Address::display_name_slice(from)),
|
||||
tags: TagString(tags_string, colors),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ impl std::fmt::Display for OfflineListing {
|
|||
|
||||
impl OfflineListing {
|
||||
pub fn new(cursor_pos: (AccountHash, MailboxHash)) -> Box<Self> {
|
||||
Box::new(OfflineListing {
|
||||
Box::new(Self {
|
||||
cursor_pos,
|
||||
_row_updates: SmallVec::new(),
|
||||
_selection: HashMap::default(),
|
||||
|
|
|
@ -667,7 +667,7 @@ impl std::fmt::Display for PlainListing {
|
|||
|
||||
impl PlainListing {
|
||||
pub fn new(parent: ComponentId, coordinates: (AccountHash, MailboxHash)) -> Box<Self> {
|
||||
Box::new(PlainListing {
|
||||
Box::new(Self {
|
||||
cursor_pos: (AccountHash::default(), MailboxHash::default(), 0),
|
||||
new_cursor_pos: (coordinates.0, coordinates.1, 0),
|
||||
length: 0,
|
||||
|
|
|
@ -321,7 +321,7 @@ impl MailListingTrait for ThreadListing {
|
|||
prev_group = threads.find_group(thread_node.group);
|
||||
|
||||
let mut entry_strings = self.make_entry_string(&envelope, context);
|
||||
entry_strings.subject = SubjectString(ThreadListing::make_thread_entry(
|
||||
entry_strings.subject = SubjectString(Self::make_thread_entry(
|
||||
&envelope,
|
||||
indentation,
|
||||
thread_node_hash,
|
||||
|
@ -775,9 +775,9 @@ impl ThreadListing {
|
|||
pub fn new(
|
||||
parent: ComponentId,
|
||||
coordinates: (AccountHash, MailboxHash),
|
||||
context: &mut Context,
|
||||
context: &Context,
|
||||
) -> Box<Self> {
|
||||
Box::new(ThreadListing {
|
||||
Box::new(Self {
|
||||
cursor_pos: (coordinates.0, MailboxHash::default(), 0),
|
||||
new_cursor_pos: (coordinates.0, coordinates.1, 0),
|
||||
length: 0,
|
||||
|
|
|
@ -141,13 +141,13 @@ pub fn encrypt_filter(
|
|||
Default::default(),
|
||||
ctx.encrypt(sign_keys, encrypt_keys, data)?.await?,
|
||||
);
|
||||
a.content_disposition = ContentDisposition::from(r#"attachment; filename="msg.asc""#.as_bytes());
|
||||
a.content_disposition = ContentDisposition::from(br#"attachment; filename="msg.asc""#);
|
||||
a
|
||||
};
|
||||
let mut a: AttachmentBuilder = AttachmentBuilder::new("Version: 1\n".as_bytes());
|
||||
let mut a: AttachmentBuilder = AttachmentBuilder::new(b"Version: 1\n");
|
||||
|
||||
a.set_content_type_from_bytes("application/pgp-encrypted".as_bytes());
|
||||
a.set_content_disposition(ContentDisposition::from("attachment".as_bytes()));
|
||||
a.set_content_type_from_bytes(b"application/pgp-encrypted");
|
||||
a.set_content_disposition(ContentDisposition::from(b"attachment"));
|
||||
let parts = vec![a, sig_attachment.into()];
|
||||
let boundary = ContentType::make_boundary(&parts);
|
||||
Ok(Attachment::new(
|
||||
|
|
|
@ -41,7 +41,7 @@ impl std::fmt::Display for AccountStatus {
|
|||
}
|
||||
|
||||
impl AccountStatus {
|
||||
pub fn new(account_pos: usize, theme_default: ThemeAttribute) -> AccountStatus {
|
||||
pub fn new(account_pos: usize, theme_default: ThemeAttribute) -> Self {
|
||||
let default_cell = {
|
||||
let mut ret = Cell::with_char(' ');
|
||||
ret.set_fg(theme_default.fg)
|
||||
|
@ -54,7 +54,7 @@ impl AccountStatus {
|
|||
content.grid_mut().set_growable(true);
|
||||
_ = content.resize(80, 20);
|
||||
|
||||
AccountStatus {
|
||||
Self {
|
||||
cursor: (0, 0),
|
||||
account_pos,
|
||||
content,
|
||||
|
|
|
@ -94,7 +94,7 @@ impl MailView {
|
|||
initialize_now: bool,
|
||||
context: &mut Context,
|
||||
) -> Self {
|
||||
let mut ret = MailView {
|
||||
let mut ret = Self {
|
||||
coordinates,
|
||||
dirty: true,
|
||||
contact_selector: None,
|
||||
|
|
|
@ -87,7 +87,7 @@ impl EnvelopeView {
|
|||
) -> Self {
|
||||
let view_settings = view_settings.unwrap_or_default();
|
||||
let body = Box::new(AttachmentBuilder::new(&mail.bytes).build());
|
||||
let mut ret = EnvelopeView {
|
||||
let mut ret = Self {
|
||||
pager: pager.unwrap_or_default(),
|
||||
subview,
|
||||
dirty: true,
|
||||
|
@ -221,7 +221,7 @@ impl EnvelopeView {
|
|||
}
|
||||
}
|
||||
for a in parts {
|
||||
EnvelopeView::attachment_to_display_helper(
|
||||
Self::attachment_to_display_helper(
|
||||
a,
|
||||
main_loop_handler,
|
||||
active_jobs,
|
||||
|
@ -271,7 +271,7 @@ impl EnvelopeView {
|
|||
job_id: handle.job_id,
|
||||
display: {
|
||||
let mut v = vec![];
|
||||
EnvelopeView::attachment_to_display_helper(
|
||||
Self::attachment_to_display_helper(
|
||||
&parts[0],
|
||||
main_loop_handler,
|
||||
active_jobs,
|
||||
|
@ -288,7 +288,7 @@ impl EnvelopeView {
|
|||
inner: Box::new(a.clone()),
|
||||
display: {
|
||||
let mut v = vec![];
|
||||
EnvelopeView::attachment_to_display_helper(
|
||||
Self::attachment_to_display_helper(
|
||||
&parts[0],
|
||||
main_loop_handler,
|
||||
active_jobs,
|
||||
|
@ -342,7 +342,7 @@ impl EnvelopeView {
|
|||
}
|
||||
_ => {
|
||||
for a in parts {
|
||||
EnvelopeView::attachment_to_display_helper(
|
||||
Self::attachment_to_display_helper(
|
||||
a,
|
||||
main_loop_handler,
|
||||
active_jobs,
|
||||
|
@ -1269,7 +1269,7 @@ impl Component for EnvelopeView {
|
|||
.replies
|
||||
.push_back(UIEvent::StatusEvent(StatusEvent::BufClear));
|
||||
if let Some(attachment) = self.open_attachment(lidx, context) {
|
||||
if let Ok(()) = crate::mailcap::MailcapEntry::execute(attachment, context) {
|
||||
if crate::mailcap::MailcapEntry::execute(attachment, context).is_ok() {
|
||||
self.set_dirty(true);
|
||||
} else {
|
||||
context.replies.push_back(UIEvent::StatusEvent(
|
||||
|
@ -1411,7 +1411,7 @@ impl Component for EnvelopeView {
|
|||
ContentType::MessageRfc822 => {
|
||||
match Mail::new(attachment.body().to_vec(), Some(Flag::SEEN)) {
|
||||
Ok(wrapper) => {
|
||||
self.subview = Some(Box::new(EnvelopeView::new(
|
||||
self.subview = Some(Box::new(Self::new(
|
||||
wrapper,
|
||||
None,
|
||||
None,
|
||||
|
|
|
@ -76,7 +76,7 @@ impl std::fmt::Display for ViewFilter {
|
|||
}
|
||||
|
||||
impl ViewFilter {
|
||||
pub fn new_html(body: &Attachment, context: &mut Context) -> Result<Self> {
|
||||
pub fn new_html(body: &Attachment, context: &Context) -> Result<Self> {
|
||||
fn run(cmd: &str, args: &[&str], bytes: &[u8]) -> Result<String> {
|
||||
let mut html_filter = Command::new(cmd)
|
||||
.args(args)
|
||||
|
@ -306,11 +306,7 @@ impl ViewFilter {
|
|||
})
|
||||
}
|
||||
|
||||
fn html_process_event(
|
||||
_self: &mut ViewFilter,
|
||||
event: &mut UIEvent,
|
||||
context: &mut Context,
|
||||
) -> bool {
|
||||
fn html_process_event(_self: &mut Self, event: &mut UIEvent, context: &mut Context) -> bool {
|
||||
if matches!(event, UIEvent::Input(key) if *key == context.settings.shortcuts.envelope_view.open_html)
|
||||
{
|
||||
let command = context
|
||||
|
@ -346,9 +342,9 @@ impl ViewFilter {
|
|||
))
|
||||
}) {
|
||||
Ok((p, child)) => {
|
||||
context.replies.push_back(UIEvent::StatusEvent(
|
||||
StatusEvent::UpdateSubStatus(command.to_string()),
|
||||
));
|
||||
context
|
||||
.replies
|
||||
.push_back(UIEvent::StatusEvent(StatusEvent::UpdateSubStatus(command)));
|
||||
context.temp_files.push(p);
|
||||
context.children.push(child);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ use melib::{text::Truncate, Envelope, Error, Mail, Result};
|
|||
use super::{EnvelopeView, MailView, ViewSettings};
|
||||
use crate::{jobs::JoinHandle, mailbox_settings, Component, Context, ShortcutMaps, UIEvent};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum PendingReplyAction {
|
||||
Reply,
|
||||
ReplyToAuthor,
|
||||
|
@ -149,7 +149,7 @@ impl MailViewState {
|
|||
}),
|
||||
context.main_loop_handler.clone(),
|
||||
));
|
||||
self_.state = MailViewState::Loaded {
|
||||
self_.state = Self::Loaded {
|
||||
env,
|
||||
bytes,
|
||||
env_view,
|
||||
|
@ -192,7 +192,7 @@ impl MailViewState {
|
|||
|
||||
impl Default for MailViewState {
|
||||
fn default() -> Self {
|
||||
MailViewState::Init {
|
||||
Self::Init {
|
||||
pending_action: None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ impl ThreadView {
|
|||
focus: Option<ThreadViewFocus>,
|
||||
context: &mut Context,
|
||||
) -> Self {
|
||||
let mut view = ThreadView {
|
||||
let mut view = Self {
|
||||
reversed: false,
|
||||
coordinates,
|
||||
thread_group,
|
||||
|
@ -147,10 +147,8 @@ impl ThreadView {
|
|||
{
|
||||
self.entries[new_cursor].hidden = old_entries[old_cursor].hidden;
|
||||
old_cursor += 1;
|
||||
new_cursor += 1;
|
||||
} else {
|
||||
new_cursor += 1;
|
||||
}
|
||||
new_cursor += 1;
|
||||
self.recalc_visible_entries();
|
||||
}
|
||||
|
||||
|
@ -898,7 +896,10 @@ impl Component for ThreadView {
|
|||
}
|
||||
|
||||
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
|
||||
if let (UIEvent::Action(Listing(OpenInNewTab)), false) = (&event, self.entries.is_empty()) {
|
||||
if matches!(
|
||||
(&event, self.entries.is_empty()),
|
||||
(UIEvent::Action(Listing(OpenInNewTab)), false)
|
||||
) {
|
||||
// Handle this before self.mailview does
|
||||
let mut new_tab = Self::new(
|
||||
self.coordinates,
|
||||
|
|
|
@ -96,7 +96,7 @@ impl MailboxManager {
|
|||
let theme_default = crate::conf::value(context, "theme_default");
|
||||
let mut data_columns = DataColumns::default();
|
||||
data_columns.theme_config.set_single_theme(theme_default);
|
||||
MailboxManager {
|
||||
Self {
|
||||
cursor_pos: 0,
|
||||
new_cursor_pos: 0,
|
||||
account_hash,
|
||||
|
@ -117,7 +117,7 @@ impl MailboxManager {
|
|||
}
|
||||
}
|
||||
|
||||
fn initialize(&mut self, context: &mut Context) {
|
||||
fn initialize(&mut self, context: &Context) {
|
||||
let account = &context.accounts[self.account_pos];
|
||||
self.length = account.mailbox_entries.len();
|
||||
let mut entries = account.mailbox_entries.clone();
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
//! Implements [RFC 1524 A User Agent Configuration Mechanism For Multimedia
|
||||
//! Mail Format Information](https://www.rfc-editor.org/rfc/inline-errata/rfc1524.html)
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
io::{Read, Write},
|
||||
path::PathBuf,
|
||||
process::{Command, Stdio},
|
||||
|
@ -77,7 +76,6 @@ impl MailcapEntry {
|
|||
}
|
||||
}
|
||||
|
||||
let mut hash_map = HashMap::new();
|
||||
let mut content = String::new();
|
||||
|
||||
std::fs::File::open(mailcap_path.as_path())?.read_to_string(&mut content)?;
|
||||
|
@ -111,13 +109,12 @@ impl MailcapEntry {
|
|||
}
|
||||
}
|
||||
|
||||
result = Some(MailcapEntry {
|
||||
result = Some(Self {
|
||||
command: cmd.to_string(),
|
||||
copiousoutput,
|
||||
});
|
||||
break;
|
||||
}
|
||||
hash_map.insert(key.to_string(), cmd.to_string());
|
||||
} else {
|
||||
let mut parts_iter = l.split(';');
|
||||
let key = parts_iter.next().unwrap();
|
||||
|
@ -134,25 +131,23 @@ impl MailcapEntry {
|
|||
}
|
||||
}
|
||||
|
||||
result = Some(MailcapEntry {
|
||||
result = Some(Self {
|
||||
command: cmd.to_string(),
|
||||
copiousoutput,
|
||||
});
|
||||
break;
|
||||
}
|
||||
hash_map.insert(key.to_string(), cmd.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
match result {
|
||||
None => Err(Error::new("Not found")),
|
||||
Some(MailcapEntry {
|
||||
Some(Self {
|
||||
command,
|
||||
copiousoutput,
|
||||
}) => {
|
||||
let parts = split_command!(command);
|
||||
let (cmd, args) = (parts[0], &parts[1..]);
|
||||
let mut f = None;
|
||||
let mut needs_stdin = true;
|
||||
let params = a.parameters();
|
||||
/* [ref:TODO]: See mailcap(5)
|
||||
|
@ -173,7 +168,6 @@ impl MailcapEntry {
|
|||
true,
|
||||
)?;
|
||||
let p = _f.path().display().to_string();
|
||||
f = Some(_f);
|
||||
Ok(p)
|
||||
}
|
||||
"%t" => Ok(a.content_type().to_string()),
|
||||
|
|
|
@ -49,7 +49,7 @@ mod dbus {
|
|||
|
||||
impl DbusNotifications {
|
||||
pub fn new(context: &Context) -> Self {
|
||||
DbusNotifications {
|
||||
Self {
|
||||
rate_limit: RateLimit::new(
|
||||
1000,
|
||||
1000,
|
||||
|
@ -183,7 +183,7 @@ pub struct NotificationCommand {
|
|||
|
||||
impl NotificationCommand {
|
||||
pub fn new() -> Self {
|
||||
NotificationCommand::default()
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,12 +213,13 @@ impl Component for NotificationCommand {
|
|||
}
|
||||
}
|
||||
|
||||
let mut script = context.settings.notifications.script.as_ref();
|
||||
if *kind == Some(NotificationType::NewMail)
|
||||
let script = if *kind == Some(NotificationType::NewMail)
|
||||
&& context.settings.notifications.new_mail_script.is_some()
|
||||
{
|
||||
script = context.settings.notifications.new_mail_script.as_ref();
|
||||
}
|
||||
context.settings.notifications.new_mail_script.as_ref()
|
||||
} else {
|
||||
context.settings.notifications.script.as_ref()
|
||||
};
|
||||
|
||||
if let Some(ref bin) = script {
|
||||
match Command::new(bin)
|
||||
|
|
|
@ -216,7 +216,7 @@ pub async fn insert(
|
|||
.unwrap_or_default(),
|
||||
envelope.field_references_to_string(),
|
||||
i64::from(envelope.flags().bits()),
|
||||
if envelope.has_attachments() { 1 } else { 0 },
|
||||
i32::from(envelope.has_attachments()),
|
||||
body,
|
||||
envelope.date().to_be_bytes().to_vec()
|
||||
],
|
||||
|
@ -253,7 +253,7 @@ pub fn remove(env_hash: EnvelopeHash) -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn index(context: &mut crate::state::Context, account_index: usize) -> ResultFuture<()> {
|
||||
pub fn index(context: &crate::state::Context, account_index: usize) -> ResultFuture<()> {
|
||||
let account = &context.accounts[account_index];
|
||||
let (acc_name, acc_mutex, backend_mutex): (String, Arc<RwLock<_>>, Arc<_>) = (
|
||||
account.name().to_string(),
|
||||
|
@ -325,7 +325,7 @@ pub fn index(context: &mut crate::state::Context, account_index: usize) -> Resul
|
|||
.unwrap_or_default(),
|
||||
e.field_references_to_string(),
|
||||
i64::from(e.flags().bits()),
|
||||
if e.has_attachments() { 1 } else { 0 },
|
||||
i32::from(e.has_attachments()),
|
||||
body,
|
||||
e.date().to_be_bytes().to_vec()
|
||||
],
|
||||
|
|
|
@ -160,7 +160,7 @@ impl Context {
|
|||
}
|
||||
|
||||
pub fn is_online_idx(&mut self, account_pos: usize) -> Result<()> {
|
||||
let Context {
|
||||
let Self {
|
||||
ref mut accounts,
|
||||
ref mut replies,
|
||||
..
|
||||
|
@ -241,7 +241,7 @@ impl Context {
|
|||
let accounts = accounts.into_iter().map(|acc| (acc.hash(), acc)).collect();
|
||||
let working = Arc::new(());
|
||||
let control = Arc::downgrade(&working);
|
||||
Context {
|
||||
Self {
|
||||
accounts,
|
||||
settings,
|
||||
dirty_areas: VecDeque::with_capacity(0),
|
||||
|
@ -410,7 +410,7 @@ impl State {
|
|||
Screen::draw_horizontal_segment_no_color
|
||||
});
|
||||
let message_box = DisplayMessageBox::new(&screen);
|
||||
let mut s = State {
|
||||
let mut s = Self {
|
||||
screen,
|
||||
child: None,
|
||||
mode: UIMode::Normal,
|
||||
|
@ -703,7 +703,7 @@ impl State {
|
|||
}
|
||||
|
||||
pub fn can_quit_cleanly(&mut self) -> bool {
|
||||
let State {
|
||||
let Self {
|
||||
ref mut components,
|
||||
ref context,
|
||||
..
|
||||
|
@ -800,7 +800,7 @@ impl State {
|
|||
});
|
||||
return;
|
||||
}
|
||||
match crate::sqlite3::index(&mut self.context, account_index) {
|
||||
match crate::sqlite3::index(&self.context, account_index) {
|
||||
Ok(job) => {
|
||||
let handle = self
|
||||
.context
|
||||
|
@ -928,7 +928,7 @@ impl State {
|
|||
));
|
||||
|
||||
self.overlay.insert(new.id(), new);
|
||||
} else if let Action::ReloadConfiguration = action {
|
||||
} else if matches!(action, Action::ReloadConfiguration) {
|
||||
match Settings::new().and_then(|new_settings| {
|
||||
let old_accounts = self
|
||||
.context
|
||||
|
|
|
@ -37,7 +37,7 @@ impl std::fmt::Display for SVGScreenshotFilter {
|
|||
|
||||
impl SVGScreenshotFilter {
|
||||
pub fn new() -> Self {
|
||||
SVGScreenshotFilter {
|
||||
Self {
|
||||
save_screenshot: false,
|
||||
id: ComponentId::default(),
|
||||
}
|
||||
|
@ -431,20 +431,22 @@ impl Component for SVGScreenshotFilter {
|
|||
kind: None,
|
||||
});
|
||||
}
|
||||
|
||||
fn process_event(&mut self, event: &mut UIEvent, _context: &mut Context) -> bool {
|
||||
if let UIEvent::Input(Key::F(6)) = event {
|
||||
if matches!(
|
||||
event,
|
||||
UIEvent::Input(Key::F(6)) | UIEvent::CmdInput(Key::F(6))
|
||||
) {
|
||||
self.save_screenshot = true;
|
||||
true
|
||||
} else if let UIEvent::CmdInput(Key::F(6)) = event {
|
||||
self.save_screenshot = true;
|
||||
true
|
||||
} else if let UIEvent::EmbeddedInput((Key::F(6), _)) = event {
|
||||
} else if matches!(event, UIEvent::EmbeddedInput((Key::F(6), _))) {
|
||||
self.save_screenshot = true;
|
||||
false
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fn set_dirty(&mut self, _value: bool) {}
|
||||
|
||||
fn is_dirty(&self) -> bool {
|
||||
|
|
|
@ -145,7 +145,7 @@ pub struct BraillePixelIter {
|
|||
|
||||
impl From<&[u16]> for BraillePixelIter {
|
||||
fn from(from: &[u16]) -> Self {
|
||||
BraillePixelIter {
|
||||
Self {
|
||||
columns: [
|
||||
Braille16bitColumn {
|
||||
bitmaps: (
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -314,7 +314,7 @@ impl EmbeddedGrid {
|
|||
|
||||
pub fn process_byte(&mut self, stdin: &mut std::fs::File, byte: u8) {
|
||||
let area = self.area();
|
||||
let EmbeddedGrid {
|
||||
let Self {
|
||||
ref mut cursor,
|
||||
ref mut scroll_region,
|
||||
ref mut terminal_size,
|
||||
|
|
|
@ -173,31 +173,31 @@ impl std::fmt::Display for Key {
|
|||
|
||||
impl<'a> From<&'a String> for Key {
|
||||
fn from(v: &'a String) -> Self {
|
||||
Key::Paste(v.to_string())
|
||||
Self::Paste(v.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<TermionKey> for Key {
|
||||
fn from(k: TermionKey) -> Self {
|
||||
match k {
|
||||
TermionKey::Backspace => Key::Backspace,
|
||||
TermionKey::Left => Key::Left,
|
||||
TermionKey::Right => Key::Right,
|
||||
TermionKey::Up => Key::Up,
|
||||
TermionKey::Down => Key::Down,
|
||||
TermionKey::Home => Key::Home,
|
||||
TermionKey::End => Key::End,
|
||||
TermionKey::PageUp => Key::PageUp,
|
||||
TermionKey::PageDown => Key::PageDown,
|
||||
TermionKey::Delete => Key::Delete,
|
||||
TermionKey::Insert => Key::Insert,
|
||||
TermionKey::F(u) => Key::F(u),
|
||||
TermionKey::Char(c) => Key::Char(c),
|
||||
TermionKey::Alt(c) => Key::Alt(c),
|
||||
TermionKey::Ctrl(c) => Key::Ctrl(c),
|
||||
TermionKey::Null => Key::Null,
|
||||
TermionKey::Esc => Key::Esc,
|
||||
_ => Key::Char(' '),
|
||||
TermionKey::Backspace => Self::Backspace,
|
||||
TermionKey::Left => Self::Left,
|
||||
TermionKey::Right => Self::Right,
|
||||
TermionKey::Up => Self::Up,
|
||||
TermionKey::Down => Self::Down,
|
||||
TermionKey::Home => Self::Home,
|
||||
TermionKey::End => Self::End,
|
||||
TermionKey::PageUp => Self::PageUp,
|
||||
TermionKey::PageDown => Self::PageDown,
|
||||
TermionKey::Delete => Self::Delete,
|
||||
TermionKey::Insert => Self::Insert,
|
||||
TermionKey::F(u) => Self::F(u),
|
||||
TermionKey::Char(c) => Self::Char(c),
|
||||
TermionKey::Alt(c) => Self::Alt(c),
|
||||
TermionKey::Ctrl(c) => Self::Ctrl(c),
|
||||
TermionKey::Null => Self::Null,
|
||||
TermionKey::Esc => Self::Esc,
|
||||
_ => Self::Char(' '),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -399,27 +399,27 @@ impl Serialize for Key {
|
|||
S: Serializer,
|
||||
{
|
||||
match self {
|
||||
Key::Backspace => serializer.serialize_str("Backspace"),
|
||||
Key::Left => serializer.serialize_str("Left"),
|
||||
Key::Right => serializer.serialize_str("Right"),
|
||||
Key::Up => serializer.serialize_str("Up"),
|
||||
Key::Down => serializer.serialize_str("Down"),
|
||||
Key::Home => serializer.serialize_str("Home"),
|
||||
Key::End => serializer.serialize_str("End"),
|
||||
Key::PageUp => serializer.serialize_str("PageUp"),
|
||||
Key::PageDown => serializer.serialize_str("PageDown"),
|
||||
Key::Delete => serializer.serialize_str("Delete"),
|
||||
Key::Insert => serializer.serialize_str("Insert"),
|
||||
Key::Esc => serializer.serialize_str("Esc"),
|
||||
Key::Char('\n') => serializer.serialize_str("Enter"),
|
||||
Key::Char('\t') => serializer.serialize_str("Tab"),
|
||||
Key::Char(c) => serializer.serialize_char(*c),
|
||||
Key::F(n) => serializer.serialize_str(&format!("F{}", n)),
|
||||
Key::Alt(c) => serializer.serialize_str(&format!("M-{}", c)),
|
||||
Key::Ctrl(c) => serializer.serialize_str(&format!("C-{}", c)),
|
||||
Key::Null => serializer.serialize_str("Null"),
|
||||
Key::Mouse(mev) => mev.serialize(serializer),
|
||||
Key::Paste(s) => serializer.serialize_str(s),
|
||||
Self::Backspace => serializer.serialize_str("Backspace"),
|
||||
Self::Left => serializer.serialize_str("Left"),
|
||||
Self::Right => serializer.serialize_str("Right"),
|
||||
Self::Up => serializer.serialize_str("Up"),
|
||||
Self::Down => serializer.serialize_str("Down"),
|
||||
Self::Home => serializer.serialize_str("Home"),
|
||||
Self::End => serializer.serialize_str("End"),
|
||||
Self::PageUp => serializer.serialize_str("PageUp"),
|
||||
Self::PageDown => serializer.serialize_str("PageDown"),
|
||||
Self::Delete => serializer.serialize_str("Delete"),
|
||||
Self::Insert => serializer.serialize_str("Insert"),
|
||||
Self::Esc => serializer.serialize_str("Esc"),
|
||||
Self::Char('\n') => serializer.serialize_str("Enter"),
|
||||
Self::Char('\t') => serializer.serialize_str("Tab"),
|
||||
Self::Char(c) => serializer.serialize_char(*c),
|
||||
Self::F(n) => serializer.serialize_str(&format!("F{}", n)),
|
||||
Self::Alt(c) => serializer.serialize_str(&format!("M-{}", c)),
|
||||
Self::Ctrl(c) => serializer.serialize_str(&format!("C-{}", c)),
|
||||
Self::Null => serializer.serialize_str("Null"),
|
||||
Self::Mouse(mev) => mev.serialize(serializer),
|
||||
Self::Paste(s) => serializer.serialize_str(s),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ type DrawHorizontalSegmentFn = fn(&mut CellBuffer, &mut StateStdout, usize, usiz
|
|||
pub struct ScreenGeneration((u64, u64));
|
||||
|
||||
impl ScreenGeneration {
|
||||
pub const NIL: ScreenGeneration = Self((0, 0));
|
||||
pub const NIL: Self = Self((0, 0));
|
||||
|
||||
#[inline]
|
||||
pub fn next(self) -> Self {
|
||||
|
@ -234,7 +234,7 @@ impl Screen<Tty> {
|
|||
Self::init(Tty {
|
||||
stdout: None,
|
||||
mouse: false,
|
||||
draw_horizontal_segment_fn: Screen::draw_horizontal_segment,
|
||||
draw_horizontal_segment_fn: Self::draw_horizontal_segment,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,10 @@ impl Screen<Tty> {
|
|||
}
|
||||
|
||||
pub fn switch_to_alternate_screen(&mut self, context: &crate::Context) {
|
||||
let mut stdout = BufWriter::with_capacity(240 * 80, Box::new(std::io::stdout()) as _);
|
||||
let mut stdout = BufWriter::with_capacity(
|
||||
240 * 80,
|
||||
Box::new(std::io::stdout()) as Box<dyn std::io::Write>,
|
||||
);
|
||||
|
||||
write!(
|
||||
&mut stdout,
|
||||
|
|
|
@ -30,7 +30,7 @@ pub struct UText {
|
|||
|
||||
impl UText {
|
||||
pub fn new(content: String) -> Self {
|
||||
UText {
|
||||
Self {
|
||||
cursor_pos: content.len(),
|
||||
grapheme_cursor_pos: content.split_graphemes().len(),
|
||||
content,
|
||||
|
|
|
@ -117,12 +117,12 @@ pub enum NotificationType {
|
|||
impl std::fmt::Display for NotificationType {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match *self {
|
||||
NotificationType::Info => write!(f, "info"),
|
||||
NotificationType::Error(melib::error::ErrorKind::None) => write!(f, "error"),
|
||||
NotificationType::Error(kind) => write!(f, "error: {}", kind),
|
||||
NotificationType::NewMail => write!(f, "new mail"),
|
||||
NotificationType::SentMail => write!(f, "sent mail"),
|
||||
NotificationType::Saved => write!(f, "saved"),
|
||||
Self::Info => write!(f, "info"),
|
||||
Self::Error(melib::error::ErrorKind::None) => write!(f, "error"),
|
||||
Self::Error(kind) => write!(f, "error: {}", kind),
|
||||
Self::NewMail => write!(f, "new mail"),
|
||||
Self::SentMail => write!(f, "sent mail"),
|
||||
Self::Saved => write!(f, "saved"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ impl std::fmt::Debug for CallbackFn {
|
|||
|
||||
impl From<RefreshEvent> for UIEvent {
|
||||
fn from(event: RefreshEvent) -> Self {
|
||||
UIEvent::RefreshEvent(Box::new(event))
|
||||
Self::RefreshEvent(Box::new(event))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,11 +207,11 @@ impl std::fmt::Display for UIMode {
|
|||
f,
|
||||
"{}",
|
||||
match *self {
|
||||
UIMode::Normal => "NORMAL",
|
||||
UIMode::Insert => "INSERT",
|
||||
UIMode::Command => "COMMAND",
|
||||
UIMode::Fork => "FORK",
|
||||
UIMode::Embedded => "EMBEDDED",
|
||||
Self::Normal => "NORMAL",
|
||||
Self::Insert => "INSERT",
|
||||
Self::Command => "COMMAND",
|
||||
Self::Fork => "FORK",
|
||||
Self::Embedded => "EMBEDDED",
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -233,15 +233,15 @@ pub mod segment_tree {
|
|||
}
|
||||
|
||||
impl From<SmallVec<[u8; 1024]>> for SegmentTree {
|
||||
fn from(val: SmallVec<[u8; 1024]>) -> SegmentTree {
|
||||
SegmentTree::new(val)
|
||||
fn from(val: SmallVec<[u8; 1024]>) -> Self {
|
||||
Self::new(val)
|
||||
}
|
||||
}
|
||||
|
||||
impl SegmentTree {
|
||||
pub fn new(val: SmallVec<[u8; 1024]>) -> SegmentTree {
|
||||
pub fn new(val: SmallVec<[u8; 1024]>) -> Self {
|
||||
if val.is_empty() {
|
||||
return SegmentTree {
|
||||
return Self {
|
||||
array: val.clone(),
|
||||
tree: val,
|
||||
};
|
||||
|
@ -262,7 +262,7 @@ pub mod segment_tree {
|
|||
segment_tree[i] = std::cmp::max(segment_tree[2 * i], segment_tree[2 * i + 1]);
|
||||
}
|
||||
|
||||
SegmentTree {
|
||||
Self {
|
||||
array: val,
|
||||
tree: segment_tree,
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ pub struct RateLimit {
|
|||
|
||||
impl RateLimit {
|
||||
pub fn new(reqs: u64, millis: u64, job_executor: Arc<JobExecutor>) -> Self {
|
||||
RateLimit {
|
||||
Self {
|
||||
last_tick: std::time::Instant::now(),
|
||||
timer: job_executor.create_timer(
|
||||
std::time::Duration::from_secs(0),
|
||||
|
|
|
@ -114,7 +114,7 @@ impl StatusBar {
|
|||
None => {}
|
||||
}
|
||||
|
||||
StatusBar {
|
||||
Self {
|
||||
container,
|
||||
status: String::with_capacity(256),
|
||||
status_message: String::with_capacity(256),
|
||||
|
@ -812,9 +812,12 @@ impl Component for StatusBar {
|
|||
|
||||
fn children(&self) -> IndexMap<ComponentId, &dyn Component> {
|
||||
let mut ret = IndexMap::default();
|
||||
ret.insert(self.container.id(), &self.container as _);
|
||||
ret.insert(self.ex_buffer.id(), &self.ex_buffer as _);
|
||||
ret.insert(self.progress_spinner.id(), &self.progress_spinner as _);
|
||||
ret.insert(self.container.id(), &self.container as &dyn Component);
|
||||
ret.insert(self.ex_buffer.id(), &self.ex_buffer as &dyn Component);
|
||||
ret.insert(
|
||||
self.progress_spinner.id(),
|
||||
&self.progress_spinner as &dyn Component,
|
||||
);
|
||||
ret
|
||||
}
|
||||
|
||||
|
@ -862,7 +865,7 @@ pub struct Tabbed {
|
|||
impl Tabbed {
|
||||
pub fn new(children: Vec<Box<dyn Component>>, context: &Context) -> Self {
|
||||
let pinned = children.len();
|
||||
let mut ret = Tabbed {
|
||||
let mut ret = Self {
|
||||
help_view: HelpView {
|
||||
content: Screen::<Virtual>::new(),
|
||||
curr_views: children
|
||||
|
@ -1565,7 +1568,7 @@ impl Component for Tabbed {
|
|||
fn children(&self) -> IndexMap<ComponentId, &dyn Component> {
|
||||
let mut ret = IndexMap::default();
|
||||
for c in &self.children {
|
||||
ret.insert(c.id(), c as _);
|
||||
ret.insert(c.id(), c as &dyn Component);
|
||||
}
|
||||
ret
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ impl<T: 'static + PartialEq + std::fmt::Debug + Clone + Sync + Send, F: 'static
|
|||
impl<T: 'static + PartialEq + std::fmt::Debug + Clone + Sync + Send, F: 'static + Sync + Send>
|
||||
PartialEq for Selector<T, F>
|
||||
{
|
||||
fn eq(&self, other: &Selector<T, F>) -> bool {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.entries == other.entries
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ impl<const N: usize> Default for DataColumns<N> {
|
|||
for elem in &mut data[..] {
|
||||
elem.write(cl());
|
||||
}
|
||||
let ptr = &data as *const [MaybeUninit<T>; N];
|
||||
let ptr = std::ptr::addr_of!(data);
|
||||
unsafe { (ptr as *const [T; N]).read() }
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ impl std::fmt::Debug for TextField {
|
|||
}
|
||||
|
||||
impl Default for TextField {
|
||||
fn default() -> TextField {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
inner: UText::new(String::with_capacity(256)),
|
||||
autocomplete: None,
|
||||
|
|
|
@ -49,8 +49,8 @@ impl std::fmt::Debug for Field {
|
|||
}
|
||||
|
||||
impl Default for Field {
|
||||
fn default() -> Field {
|
||||
Field::Text(TextField::default())
|
||||
fn default() -> Self {
|
||||
Self::Text(TextField::default())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,8 +253,8 @@ impl<T: 'static + std::fmt::Debug + Copy + Default + Send + Sync> FormWidget<T>
|
|||
action: (Cow<'static, str>, T),
|
||||
cursor_up_shortcut: Key,
|
||||
cursor_down_shortcut: Key,
|
||||
) -> FormWidget<T> {
|
||||
FormWidget {
|
||||
) -> Self {
|
||||
Self {
|
||||
buttons: ButtonWidget::new(action),
|
||||
focus: FormFocus::Fields,
|
||||
hide_buttons: false,
|
||||
|
@ -556,8 +556,8 @@ impl<T> ButtonWidget<T>
|
|||
where
|
||||
T: 'static + std::fmt::Debug + Copy + Default + Send + Sync,
|
||||
{
|
||||
pub fn new(init_val: (Cow<'static, str>, T)) -> ButtonWidget<T> {
|
||||
ButtonWidget {
|
||||
pub fn new(init_val: (Cow<'static, str>, T)) -> Self {
|
||||
Self {
|
||||
layout: vec![init_val.0.clone()],
|
||||
buttons: vec![init_val].into_iter().collect(),
|
||||
result: None,
|
||||
|
@ -676,7 +676,7 @@ impl AutoCompleteEntry {
|
|||
|
||||
impl From<String> for AutoCompleteEntry {
|
||||
fn from(val: String) -> Self {
|
||||
AutoCompleteEntry {
|
||||
Self {
|
||||
entry: val,
|
||||
description: String::new(),
|
||||
}
|
||||
|
@ -686,7 +686,7 @@ impl From<String> for AutoCompleteEntry {
|
|||
impl From<&(&str, &str, TokenStream)> for AutoCompleteEntry {
|
||||
fn from(val: &(&str, &str, TokenStream)) -> Self {
|
||||
let (a, b, _) = val;
|
||||
AutoCompleteEntry {
|
||||
Self {
|
||||
entry: a.to_string(),
|
||||
description: b.to_string(),
|
||||
}
|
||||
|
@ -696,7 +696,7 @@ impl From<&(&str, &str, TokenStream)> for AutoCompleteEntry {
|
|||
impl From<(String, String)> for AutoCompleteEntry {
|
||||
fn from(val: (String, String)) -> Self {
|
||||
let (a, b) = val;
|
||||
AutoCompleteEntry {
|
||||
Self {
|
||||
entry: a,
|
||||
description: b,
|
||||
}
|
||||
|
@ -731,7 +731,7 @@ impl Component for AutoComplete {
|
|||
}
|
||||
let page_no = (self.cursor.saturating_sub(1)).wrapping_div(rows);
|
||||
let top_idx = page_no * rows;
|
||||
let x_offset = if rows < self.entries.len() { 1 } else { 0 };
|
||||
let x_offset = usize::from(rows < self.entries.len());
|
||||
|
||||
grid.clear_area(area, crate::conf::value(context, "theme_default"));
|
||||
let width = self
|
||||
|
@ -817,7 +817,7 @@ impl Component for AutoComplete {
|
|||
|
||||
impl AutoComplete {
|
||||
pub fn new(entries: Vec<AutoCompleteEntry>) -> Box<Self> {
|
||||
let mut ret = AutoComplete {
|
||||
let mut ret = Self {
|
||||
entries: Vec::new(),
|
||||
cursor: 0,
|
||||
dirty: true,
|
||||
|
@ -1102,7 +1102,7 @@ impl ProgressSpinner {
|
|||
theme_attr.attrs |= Attr::REVERSE;
|
||||
}
|
||||
theme_attr.attrs |= Attr::BOLD;
|
||||
ProgressSpinner {
|
||||
Self {
|
||||
timer,
|
||||
stage: 0,
|
||||
kind: Ok(kind),
|
||||
|
|
Loading…
Reference in New Issue