summaryrefslogtreecommitdiffstats
path: root/src/tui/views.rs
diff options
context:
space:
mode:
authorSam Tay <sam.chong.tay@gmail.com>2020-06-18 18:19:37 -0700
committerSam Tay <sam.chong.tay@gmail.com>2020-06-18 18:19:37 -0700
commit2fea044264da4a35e112110164eb98f6b19295ce (patch)
treee7bad01268f1d0ea3cdf381f48b0f4dbe870c3eb /src/tui/views.rs
parent99bc14e8adb80d96ba1896b79a6c2ddec32c2513 (diff)
Parallelize markdown parsing, and do it upfront
Diffstat (limited to 'src/tui/views.rs')
-rw-r--r--src/tui/views.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/tui/views.rs b/src/tui/views.rs
index 2fc2136..e4c8649 100644
--- a/src/tui/views.rs
+++ b/src/tui/views.rs
@@ -11,7 +11,7 @@ use std::fmt;
use std::fmt::Display;
use std::rc::Rc;
-use super::markdown;
+use super::markdown::Markdown;
use crate::error::Result;
pub const NAME_QUESTION_LIST: &str = "question_list";
@@ -243,13 +243,10 @@ impl MdView {
}
/// Panics for now, to explore when result is None
- pub fn set_content<S>(&mut self, content: S)
- where
- S: Into<String>,
- {
+ pub fn set_content(&mut self, content: &Markdown) {
self.view
.call_on_name(&self.inner_name, |tv: &mut TextView| {
- tv.set_content(markdown::parse(content))
+ tv.set_content(content.clone())
})
.expect("unwrap failed in MdView.set_content")
}
@@ -310,6 +307,7 @@ impl ViewWrapper for LayoutView {
fn wrap_on_event(&mut self, event: Event) -> EventResult {
match event {
Event::WindowResize => {
+ println!("window resized");
self.size_invalidated = true;
}
Event::Char(' ') => {