Skip to content

Commit

Permalink
logging + refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Redhawk18 committed Jul 12, 2023
1 parent 400c05c commit e012b59
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ impl Application for State {
}
None => {
return self.update(Message::TabNew(FileTab {
text: "newfile".to_string(),
text: String::default(),
path: PathBuf::default(),
}))
}
},
}

Message::NewFile => {
return self.update(Message::TabNew(FileTab {
text: "newfile".to_string(),
text: String::default(),
path: PathBuf::default(),
}))
}
Expand Down Expand Up @@ -106,20 +106,20 @@ impl Application for State {
file_dialog::save_file(tab.text.as_str(), tab.path.as_path()).unwrap();
}
None => return Command::none(),
},
}

Message::SaveAs => match self.active_tab {
Some(index) => {
let tab = self.tabs.get(index).unwrap();
file_dialog::save_as(tab.text.as_str(), tab.path.as_path()).unwrap();
}
None => return Command::none(),
},
}

Message::Quit => std::process::exit(0),

Message::TabNew(tab) => {
log::info!("new tab");
log::info!("New tab");
self.tabs.push(tab);
self.active_tab = Some(self.tabs.len() - 1);
}
Expand All @@ -130,8 +130,8 @@ impl Application for State {
}

Message::TabClosed(index) => {
log::info!("Closed tab {}", index);
self.tabs.remove(index);
//println!("active tab before: {}", self.active_tab);
self.active_tab = if self.tabs.is_empty() {
Some(0)
} else {
Expand Down

0 comments on commit e012b59

Please sign in to comment.