diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-04-10 23:37:20 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:44 +0300 |
commit | 9bc76e3bcb837352b9c31d8875514d9974b84119 (patch) | |
tree | 2d7db5426d690f5868f304fa7b614c615e0585a8 /ui/src/components/mail/view/envelope.rs | |
parent | 106744c7ca4e5444d993a04c23bc04d93e2bfa6a (diff) |
ui: unwrap UIEventType
Diffstat (limited to 'ui/src/components/mail/view/envelope.rs')
-rw-r--r-- | ui/src/components/mail/view/envelope.rs | 100 |
1 files changed, 42 insertions, 58 deletions
diff --git a/ui/src/components/mail/view/envelope.rs b/ui/src/components/mail/view/envelope.rs index 13217a5f..4d391d74 100644 --- a/ui/src/components/mail/view/envelope.rs +++ b/ui/src/components/mail/view/envelope.rs @@ -107,16 +107,13 @@ impl EnvelopeView { .stdout(Stdio::piped()) .spawn(); if command_obj.is_err() { - context.replies.push_back(UIEvent { - id: 0, - event_type: UIEventType::Notification( - Some(format!( - "Failed to start html filter process: {}", - filter_invocation, - )), - String::new(), - ), - }); + context.replies.push_back(UIEvent::Notification( + Some(format!( + "Failed to start html filter process: {}", + filter_invocation, + )), + String::new(), + )); return; } @@ -372,20 +369,19 @@ impl Component for EnvelopeView { return true; } } - match event.event_type { - UIEventType::Input(Key::Esc) | UIEventType::Input(Key::Alt('')) => { + match *event { + UIEvent::Input(Key::Esc) | UIEvent::Input(Key::Alt('')) => { self.cmd_buf.clear(); - context.replies.push_back(UIEvent { - id: 0, - event_type: UIEventType::StatusEvent(StatusEvent::BufClear), - }); + context + .replies + .push_back(UIEvent::StatusEvent(StatusEvent::BufClear)); return true; } - UIEventType::Input(Key::Char(c)) if c >= '0' && c <= '9' => { + UIEvent::Input(Key::Char(c)) if c >= '0' && c <= '9' => { self.cmd_buf.push(c); return true; } - UIEventType::Input(Key::Char('r')) + UIEvent::Input(Key::Char('r')) if self.mode == ViewMode::Normal || self.mode == ViewMode::Raw => { self.mode = if self.mode == ViewMode::Raw { @@ -396,7 +392,7 @@ impl Component for EnvelopeView { self.dirty = true; return true; } - UIEventType::Input(Key::Char('r')) + UIEvent::Input(Key::Char('r')) if self.mode.is_attachment() || self.mode == ViewMode::Subview => { self.mode = ViewMode::Normal; @@ -404,15 +400,14 @@ impl Component for EnvelopeView { self.dirty = true; return true; } - UIEventType::Input(Key::Char('a')) + UIEvent::Input(Key::Char('a')) if !self.cmd_buf.is_empty() && self.mode == ViewMode::Normal => { let lidx = self.cmd_buf.parse::<usize>().unwrap(); self.cmd_buf.clear(); - context.replies.push_back(UIEvent { - id: 0, - event_type: UIEventType::StatusEvent(StatusEvent::BufClear), - }); + context + .replies + .push_back(UIEvent::StatusEvent(StatusEvent::BufClear)); { let envelope: &Envelope = self.wrapper.envelope(); @@ -437,15 +432,11 @@ impl Component for EnvelopeView { self.dirty = true; } ContentType::Multipart { .. } => { - context.replies.push_back(UIEvent { - id: 0, - event_type: UIEventType::StatusEvent( - StatusEvent::DisplayMessage( - "Multipart attachments are not supported yet." - .to_string(), - ), + context.replies.push_back(UIEvent::StatusEvent( + StatusEvent::DisplayMessage( + "Multipart attachments are not supported yet.".to_string(), ), - }); + )); return true; } ContentType::Unsupported { .. } => { @@ -463,40 +454,36 @@ impl Component for EnvelopeView { }); context.temp_files.push(p); } else { - context.replies.push_back(UIEvent { - id: 0, - event_type: UIEventType::StatusEvent( - StatusEvent::DisplayMessage(format!( - "Couldn't find a default application for type {}", - attachment_type - )), - ), - }); + context.replies.push_back(UIEvent::StatusEvent( + StatusEvent::DisplayMessage(format!( + "Couldn't find a default application for type {}", + attachment_type + )), + )); return true; } } } } else { - context.replies.push_back(UIEvent { - id: 0, - event_type: UIEventType::StatusEvent(StatusEvent::DisplayMessage( - format!("Attachment `{}` not found.", lidx), + context.replies.push_back(UIEvent::StatusEvent( + StatusEvent::DisplayMessage(format!( + "Attachment `{}` not found.", + lidx )), - }); + )); return true; } }; return true; } - UIEventType::Input(Key::Char('g')) + UIEvent::Input(Key::Char('g')) if !self.cmd_buf.is_empty() && self.mode == ViewMode::Url => { let lidx = self.cmd_buf.parse::<usize>().unwrap(); self.cmd_buf.clear(); - context.replies.push_back(UIEvent { - id: 0, - event_type: UIEventType::StatusEvent(StatusEvent::BufClear), - }); + context + .replies + .push_back(UIEvent::StatusEvent(StatusEvent::BufClear)); let url = { let envelope: &Envelope = self.wrapper.envelope(); let finder = LinkFinder::new(); @@ -508,12 +495,9 @@ impl Component for EnvelopeView { if let Some(u) = links.get(lidx) { u.as_str().to_string() } else { - context.replies.push_back(UIEvent { - id: 0, - event_type: UIEventType::StatusEvent(StatusEvent::DisplayMessage( - format!("Link `{}` not found.", lidx), - )), - }); + context.replies.push_back(UIEvent::StatusEvent( + StatusEvent::DisplayMessage(format!("Link `{}` not found.", lidx)), + )); return true; } }; @@ -526,7 +510,7 @@ impl Component for EnvelopeView { .expect("Failed to start xdg_open"); return true; } - UIEventType::Input(Key::Char('u')) => { + UIEvent::Input(Key::Char('u')) => { match self.mode { ViewMode::Normal => self.mode = ViewMode::Url, ViewMode::Url => self.mode = ViewMode::Normal, |