diff --git a/calcifer.project b/calcifer.project index 707695c..f68e91d 100644 --- a/calcifer.project +++ b/calcifer.project @@ -1 +1 @@ -{"categories":[{"name":"to do","content":[{"name":"clean up","description":"using the feedback from ourstory discord","id":1},{"name":"keep tree in save","description":"keep track of the opened tabs and reopens them\n","id":1},{"name":"u","description":"// Hello there","id":2}]},{"name":"in progress","content":[]},{"name":"done","content":[{"name":"mark tab as unsaved (project)","description":"when modifying a project, mark it as unsaved","id":2},{"name":"fix + color in project","description":"the '+' to add an item has a wrong color if last item in list is selected","id":3},{"name":"be able to delete category","description":"in project mode, if no focus and name is empty => delete category\n\nalready did xD I am a geniius\nfor clarification, I had a loong pause in develompent, and had forgotten I had this implemented, and while looking for where to code it, i found at the exact right place, the exact code needed","id":5},{"name":"update category layout","description":"take inspo form tab layout (number of column is max( min col, n_col +1)\nor scroll ?","id":6},{"name":"less enter trigger (project)","description":"if in a textbox, don't open the item window when enter is pressed","id":3},{"name":"be able to delete item","description":"in project mode add a button in item edit window to delete an item","id":4}]},{"name":"bugs","content":[]},{"name":"+","content":[]}]} \ No newline at end of file +{"categories":[{"name":"to do","content":[{"name":"clean up","description":"using the feedback from ourstory discord","id":1},{"name":"keep tree in save","description":"keep track of the opened tabs and reopens them\n","id":1},{"name":"open text file with calcifer directly","description":"// Hello there","id":1},{"name":"better tab names","description":"detect closest project file (within limits)\nif there is one, use its name for the tab name : \"project_name - file_name\"\n\nadd \" \" to the tab name to be able to click everywhere","id":1}]},{"name":"in progress","content":[]},{"name":"done","content":[{"name":"mark tab as unsaved (project)","description":"when modifying a project, mark it as unsaved","id":2},{"name":"fix + color in project","description":"the '+' to add an item has a wrong color if last item in list is selected","id":3},{"name":"be able to delete category","description":"in project mode, if no focus and name is empty => delete category\n\nalready did xD I am a geniius\nfor clarification, I had a loong pause in develompent, and had forgotten I had this implemented, and while looking for where to code it, i found at the exact right place, the exact code needed","id":5},{"name":"update category layout","description":"take inspo form tab layout (number of column is max( min col, n_col +1)\nor scroll ?","id":6},{"name":"less enter trigger (project)","description":"if in a textbox, don't open the item window when enter is pressed","id":3},{"name":"be able to delete item","description":"in project mode add a button in item edit window to delete an item","id":4}]},{"name":"bugs","content":[{"name":"fix undo","description":"undo struggles when switching tabs \n\npotential fix : each code textarea name depend on tabname","id":1}]},{"name":"+","content":[]}]} \ No newline at end of file diff --git a/src/core/state.rs b/src/core/state.rs index 82e0b3d..88292b9 100644 --- a/src/core/state.rs +++ b/src/core/state.rs @@ -1,58 +1,59 @@ use eframe::egui; use image::GenericImageView; -use serde::{Deserialize, Serialize}; use std::{ - error::Error, - fs, - fs::{read_to_string, OpenOptions}, - io::Write, - path::{Path, PathBuf}, + error::Error, + fs, + fs::{read_to_string, OpenOptions}, + io::Write, + path::{Path, PathBuf}, }; +use serde::Serialize; +use serde::Deserialize; #[derive(Serialize, Deserialize, Debug, PartialEq, Default)] pub struct AppState { - pub tabs: Vec, - pub theme: usize, + pub tabs: Vec, + pub theme: usize, } pub fn save_state(state: &AppState, file_path: &Path) -> Result<(), std::io::Error> { - let serialized_state = serde_json::to_string(state)?; + let serialized_state = serde_json::to_string(state)?; - if let Some(parent_dir) = file_path.parent() { - fs::create_dir_all(parent_dir)?; - } + if let Some(parent_dir) = file_path.parent() { + fs::create_dir_all(parent_dir)?; + } - let mut file = OpenOptions::new() - .write(true) - .create(true) - .truncate(true) - .open(file_path)?; + let mut file = OpenOptions::new() + .write(true) + .create(true) + .truncate(true) + .open(file_path)?; - file.write_all(serialized_state.as_bytes())?; + file.write_all(serialized_state.as_bytes())?; - println!("Saved state at {}", file_path.display()); + println!("Saved state at {}", file_path.display()); - Ok(()) + Ok(()) } pub fn load_state(file_path: &Path) -> Result { - let serialized_state = read_to_string(file_path)?; + let serialized_state = read_to_string(file_path)?; - Ok(serde_json::from_str(&serialized_state)?) + Ok(serde_json::from_str(&serialized_state)?) } pub fn load_icon() -> Result> { - let (icon_rgba, icon_width, icon_height) = { - let icon = include_bytes!("../../assets/icon.png"); - let image = image::load_from_memory(icon)?; - let rgba = image.clone().into_rgba8().to_vec(); - let (width, height) = image.dimensions(); - (rgba, width, height) - }; + let (icon_rgba, icon_width, icon_height) = { + let icon = include_bytes!("../../assets/icon.png"); + let image = image::load_from_memory(icon)?; + let rgba = image.clone().into_rgba8().to_vec(); + let (width, height) = image.dimensions(); + (rgba, width, height) + }; - Ok(egui::IconData { - rgba: icon_rgba, - width: icon_width, - height: icon_height, - }) + Ok(egui::IconData { + rgba: icon_rgba, + width: icon_width, + height: icon_height, + }) } diff --git a/src/main.rs b/src/main.rs index 68c8c3d..36f1fae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,7 +17,7 @@ const TITLE: &str = " debug"; #[cfg(not(debug_assertions))] const TITLE: &str = ""; -const ALLOWED_FILE_EXTENSIONS: [&str; 12] = ["", "rs", "toml", "txt", "project", "sh", "md", "html", "js", "css", "php", "py"]; +const ALLOWED_FILE_EXTENSIONS: [&str; 13] = ["", "rs", "toml", "txt", "project", "sh", "md", "html", "js", "css", "php", "py", "kv"]; const PROJECT_EXTENSION: &str = "project"; const TERMINAL_HEIGHT: f32 = 200.0; const TERMINAL_RANGE: Range = 100.0..600.0;