Added editor support
This commit is contained in:
parent
fc164a1382
commit
92c848dc81
4 changed files with 32 additions and 0 deletions
|
@ -7,6 +7,10 @@ authors = ["Matthias Beyer <mail@beyermatthias.de>"]
|
|||
log = "0.3"
|
||||
toml = "0.1.25"
|
||||
glob = "0.2.11"
|
||||
tempfile = "2.1.4"
|
||||
|
||||
[dependencies.libimagrt]
|
||||
path = "../libimagrt"
|
||||
|
||||
[dependencies.libimagstore]
|
||||
path = "../libimagstore"
|
||||
|
|
25
libimagentryview/src/builtin/editor.rs
Normal file
25
libimagentryview/src/builtin/editor.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
use libimagstore::store::Entry;
|
||||
use libimagrt::runtime::Runtime;
|
||||
use libimagrt::edit::edit_in_tmpfile;
|
||||
|
||||
use viewer::Viewer;
|
||||
use result::Result;
|
||||
use error::ViewErrorKind as VEK;
|
||||
use error::ViewError as VE;
|
||||
|
||||
pub struct EditorView<'a>(&'a Runtime<'a>);
|
||||
|
||||
impl<'a> EditorView<'a> {
|
||||
pub fn new(rt: &'a Runtime) -> EditorView<'a> {
|
||||
EditorView(rt)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Viewer for EditorView<'a> {
|
||||
fn view_entry(&self, e: &Entry) -> Result<()> {
|
||||
let mut entry = e.to_str().clone().to_string();
|
||||
edit_in_tmpfile(self.0, &mut entry)
|
||||
.map_err(|e| VE::new(VEK::ViewError, Some(Box::new(e))))
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
pub mod editor;
|
||||
pub mod plain;
|
||||
pub mod stdout;
|
||||
pub mod versions;
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
#[macro_use] extern crate log;
|
||||
extern crate glob;
|
||||
extern crate toml;
|
||||
extern crate tempfile;
|
||||
|
||||
extern crate libimagstore;
|
||||
extern crate libimagrt;
|
||||
#[macro_use] extern crate libimagerror;
|
||||
|
||||
pub mod error;
|
||||
|
|
Loading…
Reference in a new issue