automatic window title
This commit is contained in:
parent
6dcd9ed7df
commit
d53edc92e9
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -579,6 +579,7 @@ dependencies = [
|
||||||
"rfd",
|
"rfd",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"toml",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -6,6 +6,7 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
toml = "0.8.8"
|
||||||
eframe = "0.25.0"
|
eframe = "0.25.0"
|
||||||
rfd = "0.12.1"
|
rfd = "0.12.1"
|
||||||
egui_extras = "0.25.0"
|
egui_extras = "0.25.0"
|
||||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -8,10 +8,19 @@ use std::{path::Path, sync::Arc, time, thread};
|
||||||
use calcifer::code_editor::themes::DEFAULT_THEMES;
|
use calcifer::code_editor::themes::DEFAULT_THEMES;
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[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))]
|
#[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 TERMINAL_HEIGHT : f32 = 200.0;
|
||||||
const RED : egui::Color32 = egui::Color32::from_rgb(235, 108, 99);
|
const RED : egui::Color32 = egui::Color32::from_rgb(235, 108, 99);
|
||||||
|
@ -43,7 +52,7 @@ fn main() -> Result<(), eframe::Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
eframe::run_native(
|
eframe::run_native(
|
||||||
"Calcifer v1.0.4",
|
&format!("Calcifer v{}{}", tools::version(), TITLE),
|
||||||
options,
|
options,
|
||||||
Box::new(move |_cc| Box::from(Calcifer::from_app_state(app_state))),
|
Box::new(move |_cc| Box::from(Calcifer::from_app_state(app_state))),
|
||||||
)
|
)
|
||||||
|
@ -181,4 +190,3 @@ impl eframe::App for Calcifer {
|
||||||
self.save_state();
|
self.save_state();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
src/tools/calcifer_save.json
Normal file
1
src/tools/calcifer_save.json
Normal file
|
@ -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}
|
|
@ -40,7 +40,7 @@ impl ConfirmWindow {
|
||||||
self.proceed = true;
|
self.proceed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ui.add(egui::Button::new("Cancel")).clicked() {
|
if ui.add(egui::Button::new("No")).clicked() {
|
||||||
self.visible = false;
|
self.visible = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,6 +3,7 @@ use crate::calcifer::code_editor::Syntax;
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use crate::DISPLAY_PATH_DEPTH;
|
use crate::DISPLAY_PATH_DEPTH;
|
||||||
|
use toml::Value;
|
||||||
|
|
||||||
//my tools;
|
//my tools;
|
||||||
pub mod search;
|
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::<Vec<_>>().join("/"))
|
format!("{}>", components.iter().rev().map(|&c| c.to_string_lossy()).collect::<Vec<_>>().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)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
Loading…
Reference in a new issue