diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/command.rs | 15 | ||||
-rw-r--r-- | src/command/actions.rs | 1 | ||||
-rw-r--r-- | src/components/mail/listing.rs | 9 |
3 files changed, 25 insertions, 0 deletions
diff --git a/src/command.rs b/src/command.rs index c83008bf..562b1a5d 100644 --- a/src/command.rs +++ b/src/command.rs @@ -500,6 +500,20 @@ define_commands!([ } ) }, + { tags: ["mailto "], + desc: "mailto MAILTO_ADDRESS", + tokens: &[One(Literal("mailto")), One(QuotedStringValue)], + parser:( + fn mailto(input: &[u8]) -> IResult<&[u8], Action> { + let (input, _) = tag("mailto")(input.ltrim())?; + let (input, _) = is_a(" ")(input)?; + let (input, val) = map_res(not_line_ending, std::str::from_utf8)(input.trim())?; + let (_empty, _) = eof(input)?; + let (input, val) = melib::email::parser::generic::mailto(val.as_bytes()).map_err(|err| err.map(Into::into))?; + Ok((input, Compose(Mailto(val)))) + } + ) + }, /* Pipe pager contents to binary */ { tags: ["pipe "], desc: "pipe EXECUTABLE ARGS", @@ -931,6 +945,7 @@ fn listing_action(input: &[u8]) -> IResult<&[u8], Action> { fn compose_action(input: &[u8]) -> IResult<&[u8], Action> { alt(( add_attachment, + mailto, remove_attachment, toggle_sign, toggle_encrypt, diff --git a/src/command/actions.rs b/src/command/actions.rs index 8cc89aea..7152471e 100644 --- a/src/command/actions.rs +++ b/src/command/actions.rs @@ -89,6 +89,7 @@ pub enum ComposeAction { SaveDraft, ToggleSign, ToggleEncrypt, + Mailto(melib::Mailto), } #[derive(Debug)] diff --git a/src/components/mail/listing.rs b/src/components/mail/listing.rs index 849d2370..5a0e9d06 100644 --- a/src/components/mail/listing.rs +++ b/src/components/mail/listing.rs @@ -1889,6 +1889,15 @@ impl Component for Listing { .push_back(UIEvent::Action(Tab(New(Some(Box::new(mgr)))))); return true; } + UIEvent::Action(Action::Compose(ComposeAction::Mailto(ref mailto))) => { + let account_hash = context.accounts[self.cursor_pos.0].hash(); + let mut composer = Composer::with_account(account_hash, context); + composer.set_draft(mailto.into()); + context + .replies + .push_back(UIEvent::Action(Tab(New(Some(Box::new(composer)))))); + return true; + } UIEvent::StartupCheck(_) | UIEvent::MailboxUpdate(_) | UIEvent::EnvelopeUpdate(_) |