The EventGhost Core Plugin is the foundational plugin that provides essential infrastructure for event handling, macro execution, and system integration. It serves as the backbone for other plugins, providing core services like event processing, Python script execution, and configuration management.
pub struct EventSystem {
event_queue: Arc<Mutex<VecDeque<Event>>>,
handlers: HashMap<String, Vec<Box<dyn EventHandler>>>,
notification_system: NotificationSystem,
}
impl EventSystem {
pub fn trigger_event(&self, name: &str, payload: Value) -> Result<(), Error> {
let event = Event::new(name, payload);
self.process_event(event)
}
}
pub struct MacroEngine {
program_counter: Option<(ActionItem, usize)>,
return_stack: Vec<(ActionItem, usize)>,
execution_state: Arc<Mutex<ExecutionState>>,
}
impl MacroEngine {
pub fn execute_action(&mut self, action: ActionItem) -> Result<(), Error> {
// Action execution logic
// Flow control
// State management
}
}
- Event Processing - Event queue management - Event handler registration - Event filtering and routing - Notification system
- Macro Control - Action execution flow - Jump conditions (JumpIfElse) - Wait states and timing - AutoRepeat functionality
- Python Integration - Script execution environment - Global variable management - Python command execution - Error handling and logging
- System Services - Plugin registration and loading - Configuration management - Window management - Process control
- Core Architecture - Thread-safe event processing - Rust-based macro execution - Plugin system architecture - Configuration persistence
- Python Integration - Python/Rust FFI layer - Script execution safety - Global state management - Error propagation
Event System Implementation .. code-block:: rust
- impl EventSystem {
- pub fn register_handler(&mut self, pattern: &str, handler: Box<dyn EventHandler>) {
- self.handlers.entry(pattern.to_string())
.or_default() .push(handler);
}
- pub fn process_event(&self, event: Event) -> Result<(), Error> {
- for (pattern, handlers) in &self.handlers {
- if event.matches(pattern) {
- for handler in handlers {
handler.handle_event(&event)?;
}
}
} Ok(())
}
}
Macro Engine Implementation .. code-block:: rust
- impl MacroEngine {
- pub fn run_program(&mut self) -> Result<(), Error> {
- while let Some((item, idx)) = self.program_counter.take() {
self.execute_action(item)?;
- if self.execution_state.lock()?.is_stopped {
break;
}
self.program_counter = item.get_next_action(idx);
} Ok(())
}
}
- Unit Tests - Event system functionality - Macro execution flow - Python integration - Configuration management
- Integration Tests - Plugin interaction - Event processing chain - Macro execution scenarios - System service integration
- Performance Tests - Event throughput - Macro execution speed - Memory usage patterns - Resource management
- Event Processing - Invalid event formats - Handler failures - Queue overflow - Timeout handling
- Macro Execution - Action failures - State corruption - Resource exhaustion - Deadlock prevention
- System Integration - Plugin loading errors - Configuration failures - Resource allocation - Cleanup procedures
- Windows Integration - Win32 API usage - System event handling - Window management - Process control
- Cross-platform Support - Platform abstraction - Event system portability - Resource management - Plugin compatibility