Show changed status

This commit is contained in:
Jeremy Soller 2023-11-13 14:47:17 -07:00
parent c84a256376
commit 3716300139
No known key found for this signature in database
GPG key ID: DCFCA852D3906975
4 changed files with 80 additions and 36 deletions

View file

@ -77,7 +77,7 @@ impl Tab {
pub fn save(&mut self) {
if let Some(path) = &self.path_opt {
let editor = self.editor.lock().unwrap();
let mut editor = self.editor.lock().unwrap();
let mut text = String::new();
for line in editor.buffer().lines.iter() {
text.push_str(line.text());
@ -85,6 +85,7 @@ impl Tab {
}
match fs::write(path, text) {
Ok(()) => {
editor.set_changed(false);
log::info!("saved {:?}", path);
}
Err(err) => {
@ -96,6 +97,11 @@ impl Tab {
}
}
pub fn changed(&self) -> bool {
let editor = self.editor.lock().unwrap();
editor.changed()
}
pub fn icon(&self, size: u16) -> Icon {
match &self.path_opt {
Some(path) => mime_icon(path, size),