Pass application context to GUI. #11
@ -43,7 +43,7 @@ impl<'a> App<'a> {
|
||||
pub fn new(root_path: PathBuf) -> Result<Self> {
|
||||
trace!(target:Self::ID, "Building {}", Self::ID);
|
||||
let app = Self {
|
||||
editor_tab: EditorTab::new(None),
|
||||
editor_tab: EditorTab::new(),
|
||||
explorer: Explorer::new(&root_path)?,
|
||||
logger: Logger::new(),
|
||||
menu_bar: MenuBar::new(),
|
||||
|
||||
@ -21,25 +21,12 @@ pub struct EditorTab {
|
||||
impl EditorTab {
|
||||
pub const ID: &str = "EditorTab";
|
||||
|
||||
pub fn new(path: Option<&std::path::PathBuf>) -> Self {
|
||||
trace!(target:Self::ID, "Building EditorTab with path {path:?}");
|
||||
match path {
|
||||
None => Self {
|
||||
editors: HashMap::new(),
|
||||
tab_order: Vec::new(),
|
||||
current_editor: 0,
|
||||
},
|
||||
Some(path) => {
|
||||
let tab_order = vec![path.to_string_lossy().to_string()];
|
||||
Self {
|
||||
editors: HashMap::from([(
|
||||
tab_order.first().unwrap().to_owned(),
|
||||
Editor::new(path),
|
||||
)]),
|
||||
tab_order,
|
||||
current_editor: 0,
|
||||
}
|
||||
}
|
||||
pub fn new() -> Self {
|
||||
trace!(target:Self::ID, "Building {}", Self::ID);
|
||||
Self {
|
||||
editors: HashMap::new(),
|
||||
tab_order: Vec::new(),
|
||||
current_editor: 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user