From f9357f3b37cd5591392ed9ab33dec4fa8307a8df Mon Sep 17 00:00:00 2001 From: Kai Sickeler Date: Tue, 9 Aug 2016 19:47:13 +0200 Subject: [PATCH] Added editor --- imag-view/src/editor.rs | 24 ++++++++++++++++++++++++ imag-view/src/main.rs | 7 ++++++- 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 imag-view/src/editor.rs diff --git a/imag-view/src/editor.rs b/imag-view/src/editor.rs new file mode 100644 index 00000000..6a60b007 --- /dev/null +++ b/imag-view/src/editor.rs @@ -0,0 +1,24 @@ +use libimagstore::store::FileLockEntry; +use libimagrt::runtime::Runtime; +use libimagentryview::builtin::editor::EditorView; +use libimagentryview::viewer::Viewer; +use libimagentryview::error::ViewError as VE; + +pub struct Editor<'a> { + rt: &'a Runtime<'a>, + fle: &'a FileLockEntry<'a>, +} + +impl<'a> Editor<'a> { + pub fn new(rt: &'a Runtime, fle: &'a FileLockEntry) -> Editor<'a> { + Editor{ + rt: rt, + fle: fle, + } + } + + pub fn show(self) -> Result<(), VE> { + EditorView::new(self.rt).view_entry(self.fle) + } +} + diff --git a/imag-view/src/main.rs b/imag-view/src/main.rs index 1300a9f2..907758ae 100644 --- a/imag-view/src/main.rs +++ b/imag-view/src/main.rs @@ -34,8 +34,10 @@ use libimagentryview::builtin::versions::VersionsViewer; use libimagentryview::viewer::Viewer; mod ui; +mod editor; use ui::build_ui; +use editor::Editor; fn main() { let rt = generate_runtime_setup( "imag-view", @@ -75,7 +77,10 @@ fn main() { } else if scmd.is_present("view-in-browser") { warn!("Viewing in browser is currently not supported, switch to stdout"); } else if scmd.is_present("view-in-texteditor") { - warn!("Viewing in texteditor is currently not supported, switch to stdout"); + if let Err(e) = Editor::new(&rt, &entry).show() { + error!("Cannot view in editor: {}", e); + trace_error_exit(&e, 1); + } } else if scmd.is_present("view-in-custom") { warn!("Viewing in custom is currently not supported, switch to stdout"); }