diff --git a/lib/entry/libimagentryview/Cargo.toml b/lib/entry/libimagentryview/Cargo.toml index 635dfc80..e6236919 100644 --- a/lib/entry/libimagentryview/Cargo.toml +++ b/lib/entry/libimagentryview/Cargo.toml @@ -30,7 +30,7 @@ libimagstore = { version = "0.9.0", path = "../../../lib/core/libimagstore" libimagerror = { version = "0.9.0", path = "../../../lib/core/libimagerror" } libimagentryedit = { version = "0.9.0", path = "../../../lib/entry/libimagentryedit" } -mdcat = { version = "0.8", optional = true } +mdcat = { version = "0.11", optional = true } [dependencies.pulldown-cmark] version = "^0.1" diff --git a/lib/entry/libimagentryview/src/builtin/md.rs b/lib/entry/libimagentryview/src/builtin/md.rs index 83d247e9..ecaa0468 100644 --- a/lib/entry/libimagentryview/src/builtin/md.rs +++ b/lib/entry/libimagentryview/src/builtin/md.rs @@ -22,10 +22,9 @@ use std::io::Write; use libimagstore::store::Entry; use libimagrt::runtime::Runtime; -use mdcat::{ResourceAccess, Terminal, TerminalSize}; +use mdcat::{AnsiTerminal, ResourceAccess, TerminalSize}; use pulldown_cmark::Parser; use syntect::parsing::SyntaxSet; -use mdcat; use viewer::Viewer; use failure::Fallible as Result; @@ -34,7 +33,6 @@ use failure::Error; pub struct MarkdownViewer<'a> { rt: &'a Runtime<'a>, resource_access: ResourceAccess, - terminal: Terminal, termsize: TerminalSize, } @@ -43,7 +41,6 @@ impl<'a> MarkdownViewer<'a> { MarkdownViewer { rt, resource_access: ResourceAccess::LocalOnly, - terminal: Terminal::detect(), termsize: TerminalSize::detect().unwrap_or(TerminalSize { width: 80, height: 20, @@ -60,13 +57,15 @@ impl<'a> Viewer for MarkdownViewer<'a> { let base_dir = self.rt.rtp(); let syntax_set = SyntaxSet::load_defaults_newlines(); - mdcat::push_tty(sink, - self.terminal.clone(), - self.termsize.clone(), - parser, - base_dir, - self.resource_access.clone(), - syntax_set) + let mut term = AnsiTerminal::new(sink); + + ::mdcat::push_tty(&mut term, + self.termsize.clone(), + parser, + base_dir, + self.resource_access.clone(), + syntax_set) + .map_err(|e| e.compat()) .map_err(Error::from) } }