diff --git a/Cargo.lock b/Cargo.lock index c334ea1..e02b603 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -579,6 +579,7 @@ dependencies = [ "rfd", "serde", "serde_json", + "toml", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f48d1db..b15cee1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +toml = "0.8.8" eframe = "0.25.0" rfd = "0.12.1" egui_extras = "0.25.0" diff --git a/src/main.rs b/src/main.rs index 6892585..c3615ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,10 +8,19 @@ use std::{path::Path, sync::Arc, time, thread}; use calcifer::code_editor::themes::DEFAULT_THEMES; #[cfg(debug_assertions)] -const SAVE_PATH : &str = "/home/penwing/Documents/.saves/debug/calcifer_save.json"; +mod build { + pub const SAVE_PATH : &str = "/home/penwing/Documents/.saves/debug/calcifer_save.json"; + pub const TITLE: &str = " debug"; +} #[cfg(not(debug_assertions))] -const SAVE_PATH : &str = "/home/penwing/Documents/.saves/calcifer_save.json"; +mod build { + pub const SAVE_PATH : &str = "/home/penwing/Documents/.saves/calcifer_save.json"; + pub const TITLE: &str = ""; +} + +use build::SAVE_PATH; +use build::TITLE; const TERMINAL_HEIGHT : f32 = 200.0; const RED : egui::Color32 = egui::Color32::from_rgb(235, 108, 99); @@ -43,7 +52,7 @@ fn main() -> Result<(), eframe::Error> { } eframe::run_native( - "Calcifer v1.0.4", + &format!("Calcifer v{}{}", tools::version(), TITLE), options, Box::new(move |_cc| Box::from(Calcifer::from_app_state(app_state))), ) @@ -180,5 +189,4 @@ impl eframe::App for Calcifer { fn on_exit(&mut self, _gl : std::option::Option<&eframe::glow::Context>) { self.save_state(); } -} - +} \ No newline at end of file diff --git a/src/tools/calcifer_save.json b/src/tools/calcifer_save.json new file mode 100644 index 0000000..7b9e510 --- /dev/null +++ b/src/tools/calcifer_save.json @@ -0,0 +1 @@ +{"tabs":["/home/penwing/Documents/projects/rust/calcifer/src/tools/mod.rs","/home/penwing/Documents/projects/rust/calcifer/src/tools/tabs.rs","/home/penwing/Documents/projects/rust/calcifer/README.md","/home/penwing/Documents/projects/rust/calcifer/src/tools/terminal.rs","/home/penwing/Documents/projects/rust/calcifer/src/main.rs","/home/penwing/Documents/projects/rust/calcifer/src/calcifer.rs","/home/penwing/Documents/projects/rust/calcifer/src/calcifer/app_base.rs","/home/penwing/Documents/projects/rust/calcifer/Cargo.toml","/home/penwing/Documents/projects/rust/calcifer/src/tools/confirm.rs"],"theme":5} \ No newline at end of file diff --git a/src/tools/confirm.rs b/src/tools/confirm.rs index 88a0c7d..9cf6a99 100644 --- a/src/tools/confirm.rs +++ b/src/tools/confirm.rs @@ -40,7 +40,7 @@ impl ConfirmWindow { self.proceed = true; } - if ui.add(egui::Button::new("Cancel")).clicked() { + if ui.add(egui::Button::new("No")).clicked() { self.visible = false; } }); diff --git a/src/tools/mod.rs b/src/tools/mod.rs index 3a22204..31c0111 100644 --- a/src/tools/mod.rs +++ b/src/tools/mod.rs @@ -3,6 +3,7 @@ use crate::calcifer::code_editor::Syntax; use eframe::egui; use serde::{Serialize, Deserialize}; use crate::DISPLAY_PATH_DEPTH; +use toml::Value; //my tools; pub mod search; @@ -108,6 +109,25 @@ pub fn format_path(path: &Path) -> String { format!("{}>", components.iter().rev().map(|&c| c.to_string_lossy()).collect::>().join("/")) } +pub fn version() -> String { + // Read the contents of the Cargo.toml file + let toml_content = fs::read_to_string("Cargo.toml").expect("Failed to read Cargo.toml"); + + // Parse the TOML content + let toml: Value = toml::from_str(&toml_content).expect("Failed to parse TOML"); + + // Extract version information + if let Some(package) = toml.get("package") { + if let Some(version) = package.get("version") { + if let Some(version_string) = version.as_str() { + println!("Version: {}", version_string); + return version_string.to_string() + } + } + } + return "".to_string() +} + #[cfg(test)] mod tests; \ No newline at end of file