2020-10-16 12:29:22 +09:00
|
|
|
use crate::View;
|
|
|
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
use anyhow::Error;
|
|
|
|
|
|
|
|
pub struct Editor {
|
|
|
|
pub view: Option<View>,
|
2020-10-16 14:37:12 +09:00
|
|
|
pub should_close: bool,
|
2020-10-16 12:29:22 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Editor {
|
|
|
|
pub fn new() -> Self {
|
2020-10-16 14:37:12 +09:00
|
|
|
Self {
|
|
|
|
view: None,
|
|
|
|
should_close: false,
|
|
|
|
}
|
2020-10-16 12:29:22 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn open(&mut self, path: PathBuf, size: (u16, u16)) -> Result<(), Error> {
|
|
|
|
self.view = Some(View::open(path, size)?);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|