Merge pull request #603 from asuivelentine/imag-view/view-in-editor

get default editor
This commit is contained in:
Matthias Beyer 2016-09-04 15:36:22 +02:00 committed by GitHub
commit dfcc5c6a0e
2 changed files with 30 additions and 1 deletions

24
imag-view/src/editor.rs Normal file
View file

@ -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)
}
}

View file

@ -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");
}