Reorganize codebase into modular structure

This commit is contained in:
2025-05-09 21:37:15 -05:00
parent f4c83e31c0
commit cf1c90856f
24 changed files with 2008 additions and 817 deletions
+34
View File
@@ -0,0 +1,34 @@
// Application configuration
use std::path::PathBuf;
// Application configuration
pub struct Config {
pub assets_dir: PathBuf,
pub default_cursor: String,
pub auto_start: bool,
pub minimize_to_tray: bool,
}
impl Default for Config {
fn default() -> Self {
Self {
assets_dir: PathBuf::from("assets"),
default_cursor: String::from("default"),
auto_start: false,
minimize_to_tray: true,
}
}
}
// Load configuration from file or use defaults
pub fn load_config() -> Config {
// TODO: Implement loading from a config file
Config::default()
}
// Save configuration to file
pub fn save_config(_config: &Config) -> Result<(), String> {
// TODO: Implement saving to a config file
Ok(())
}
+58
View File
@@ -0,0 +1,58 @@
// Logging utilities
// Log levels
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum LogLevel {
Debug,
Info,
Warning,
Error,
}
// Global log level (could be made configurable)
static mut CURRENT_LOG_LEVEL: LogLevel = LogLevel::Info;
// Set the global log level
pub fn set_log_level(level: LogLevel) {
unsafe {
CURRENT_LOG_LEVEL = level;
}
}
// Get the current log level
pub fn get_log_level() -> LogLevel {
unsafe {
CURRENT_LOG_LEVEL
}
}
// Log a message at the specified level
pub fn log(level: LogLevel, message: &str) {
if level >= unsafe { CURRENT_LOG_LEVEL } {
let prefix = match level {
LogLevel::Debug => "[DEBUG]",
LogLevel::Info => "[INFO]",
LogLevel::Warning => "[WARNING]",
LogLevel::Error => "[ERROR]",
};
println!("{} {}", prefix, message);
}
}
// Convenience functions for different log levels
pub fn debug(message: &str) {
log(LogLevel::Debug, message);
}
pub fn info(message: &str) {
log(LogLevel::Info, message);
}
pub fn warning(message: &str) {
log(LogLevel::Warning, message);
}
pub fn error(message: &str) {
log(LogLevel::Error, message);
}
+4
View File
@@ -0,0 +1,4 @@
// Utility functions and helpers
pub mod config;
pub mod logging;