diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-05 01:27:13 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:50 +0300 |
commit | d3ce424361adf0b79a0a5f0e2f37d8c7e8c78b5e (patch) | |
tree | 5d3a2b8d9517ac2af2d9a4192b0cb2472a57cd9d | |
parent | 3318123870557e517c057e73575f354cb7dd5ec7 (diff) |
ui: add update and expand_headers in MailView
-rw-r--r-- | ui/src/components/mail/view.rs | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs index ba8083dc..461586a7 100644 --- a/ui/src/components/mail/view.rs +++ b/ui/src/components/mail/view.rs @@ -67,6 +67,7 @@ pub struct MailView { subview: Option<Box<Component>>, dirty: bool, mode: ViewMode, + expand_headers: bool, cmd_buf: String, id: ComponentId, @@ -110,6 +111,7 @@ impl MailView { subview, dirty: true, mode: ViewMode::Normal, + expand_headers: false, cmd_buf: String::with_capacity(4), id: ComponentId::new_v4(), @@ -279,6 +281,12 @@ impl MailView { } buf } + + pub fn update(&mut self, new_coordinates: (usize, usize, EnvelopeHash)) { + self.coordinates = new_coordinates; + self.mode = ViewMode::Normal; + self.set_dirty(); + } } impl Component for MailView { @@ -355,7 +363,7 @@ impl Component for MailView { grid[(x, y)].set_bg(Color::Default); grid[(x, y)].set_fg(Color::Default); } - let (x, y) = write_string_to_grid( + let (x, mut y) = write_string_to_grid( &format!("Message-ID: <{}>", envelope.message_id_raw()), grid, Color::Byte(33), @@ -368,6 +376,43 @@ impl Component for MailView { grid[(x, y)].set_bg(Color::Default); grid[(x, y)].set_fg(Color::Default); } + if self.expand_headers && envelope.in_reply_to().is_some() { + let (x, _y) = write_string_to_grid( + &format!("In-Reply-To: {}", envelope.in_reply_to_display().unwrap()), + grid, + Color::Byte(33), + Color::Default, + (set_y(upper_left, y + 1), bottom_right), + true, + ); + for x in x..=get_x(bottom_right) { + grid[(x, _y)].set_ch(' '); + grid[(x, _y)].set_bg(Color::Default); + grid[(x, _y)].set_fg(Color::Default); + } + let (x, _y) = write_string_to_grid( + &format!( + "References: {}", + envelope + .references() + .iter() + .map(|r| r.to_string()) + .collect::<Vec<String>>() + .join(", ") + ), + grid, + Color::Byte(33), + Color::Default, + (set_y(upper_left, _y + 1), bottom_right), + true, + ); + for x in x..=get_x(bottom_right) { + grid[(x, _y)].set_ch(' '); + grid[(x, _y)].set_bg(Color::Default); + grid[(x, _y)].set_fg(Color::Default); + } + y = _y; + } clear_area(grid, (set_y(upper_left, y + 1), set_y(bottom_right, y + 1))); context .dirty_areas @@ -656,6 +701,11 @@ impl Component for MailView { } }; } + UIEvent::Input(Key::Char('h')) => { + self.expand_headers = !self.expand_headers; + self.dirty = true; + return true; + } UIEvent::Input(Key::Char('g')) if !self.cmd_buf.is_empty() && self.mode == ViewMode::Url => { |