diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-03-18 15:41:38 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:40 +0300 |
commit | 2b06dd1aca91eaaf388d28b06c09164ba65cd542 (patch) | |
tree | 821c2fafccd2c064ba7092b3959c5487266133ab /ui/src/components/mail | |
parent | 0b76307e30aa3c0fd81df8925b0669513a83229e (diff) |
ui: fix pager from_buf reflowing incompatibility
Diffstat (limited to 'ui/src/components/mail')
-rw-r--r-- | ui/src/components/mail/view.rs | 12 | ||||
-rw-r--r-- | ui/src/components/mail/view/envelope.rs | 18 | ||||
-rw-r--r-- | ui/src/components/mail/view/html.rs | 3 |
3 files changed, 26 insertions, 7 deletions
diff --git a/ui/src/components/mail/view.rs b/ui/src/components/mail/view.rs index 3e93daa9..800a565d 100644 --- a/ui/src/components/mail/view.rs +++ b/ui/src/components/mail/view.rs @@ -326,17 +326,25 @@ impl Component for MailView { } ViewMode::Subview | ViewMode::ContactSelector(_) => {} _ => { - let buf = { + let text = { + self.attachment_to_text(&body) + /* let text = self.attachment_to_text(&body); // URL indexes must be colored (ugh..) MailView::plain_text_to_buf(&text, self.mode == ViewMode::Url) + */ }; let cursor_pos = if self.mode.is_attachment() { Some(0) } else { self.pager.as_mut().map(|p| p.cursor_pos()) }; - self.pager = Some(Pager::from_buf(buf.split_newlines(), cursor_pos)); + self.pager = Some(Pager::from_string( + text, + Some(context), + cursor_pos, + Some(width!(area)), + )); self.subview = None; } }; diff --git a/ui/src/components/mail/view/envelope.rs b/ui/src/components/mail/view/envelope.rs index e9668bd8..9f028195 100644 --- a/ui/src/components/mail/view/envelope.rs +++ b/ui/src/components/mail/view/envelope.rs @@ -160,6 +160,9 @@ impl EnvelopeView { } } } + /* + * TODO: add recolor changes so that this function returns a vector of required highlights + * to pass to write_string... pub fn plain_text_to_buf(s: &str, highlight_urls: bool) -> CellBuffer { let mut buf = CellBuffer::from(s); @@ -192,6 +195,7 @@ impl EnvelopeView { } buf } + */ } impl Component for EnvelopeView { @@ -294,17 +298,25 @@ impl Component for EnvelopeView { self.mode = ViewMode::Subview; } _ => { - let buf = { + let text = { + self.attachment_to_text(&body) + /* let text = self.attachment_to_text(&body); // URL indexes must be colored (ugh..) EnvelopeView::plain_text_to_buf(&text, self.mode == ViewMode::Url) + */ }; let cursor_pos = if self.mode.is_attachment() { Some(0) } else { self.pager.as_mut().map(|p| p.cursor_pos()) }; - self.pager = Some(Pager::from_buf(buf.split_newlines(), cursor_pos)); + self.pager = Some(Pager::from_string( + text, + Some(context), + cursor_pos, + Some(width!(area)), + )); } }; self.dirty = false; @@ -380,7 +392,7 @@ impl Component for EnvelopeView { self.mode = ViewMode::Subview; self.subview = Some(Box::new(Pager::from_string( String::from_utf8_lossy(&decode_rec(u, None)).to_string(), - context, + Some(context), None, None, ))); diff --git a/ui/src/components/mail/view/html.rs b/ui/src/components/mail/view/html.rs index bed8e216..4eb4f2bc 100644 --- a/ui/src/components/mail/view/html.rs +++ b/ui/src/components/mail/view/html.rs @@ -49,8 +49,7 @@ impl HtmlView { &html_filter.wait_with_output().unwrap().stdout, )); - let buf = MailView::plain_text_to_buf(&display_text, true); - let pager = Pager::from_buf(buf.split_newlines(), None); + let pager = Pager::from_string(display_text, None, None, None); HtmlView { pager, bytes } } } |