use rustc_hash::FxHashMap;
use crate::types::Theme;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CommandHookResult {
Continue,
Handled,
Blocked,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum KeyboardHookResult {
Continue,
Handled,
Blocked,
}
pub trait LifecycleHook: Send + Sync {
fn on_workspace_loaded(&mut self) {}
fn on_workspace_saving(&mut self) {}
fn on_pane_added(&mut self, _pane_id: usize) {}
fn on_pane_removing(&mut self, _pane_id: usize) {}
fn on_pane_focused(&mut self, _pane_id: usize) {}
fn on_closing(&mut self) {}
fn on_frame(&mut self) {}
}
pub trait CommandHook: Send + Sync {
fn before_command(&mut self, _command: &str, _args: &str) -> CommandHookResult {
CommandHookResult::Continue
}
fn after_command(&mut self, _command: &str, _args: &str, _success: bool) {}
}
pub trait KeyboardHook: Send + Sync {
fn on_key_pressed(&mut self, _key: &KeyEvent) -> KeyboardHookResult {
KeyboardHookResult::Continue
}
fn on_key_combo(&mut self, _combo: &KeyCombo) -> KeyboardHookResult {
KeyboardHookResult::Continue
}
}
pub trait ThemeHook: Send + Sync {
fn before_theme_change(&mut self, _old_theme: Theme, _new_theme: Theme) {}
fn after_theme_change(&mut self, _theme: Theme) {}
fn customize_theme(&self, _theme: Theme) -> Option<ThemeCustomization> {
None
}
}
pub trait PaneHook: Send + Sync {
fn on_pane_created(&mut self, _pane_id: usize, _pane_type: &str) {}
fn on_query_changed(&mut self, _pane_id: usize, _query: &str) {}
fn on_data_received(&mut self, _pane_id: usize) {}
fn on_pane_error(&mut self, _pane_id: usize, _error: &str) {}
}
#[derive(Debug, Clone)]
pub struct KeyEvent {
pub key: egui::Key,
pub shift: bool,
pub ctrl: bool,
pub alt: bool,
}
#[derive(Debug, Clone)]
pub struct KeyCombo {
pub key: egui::Key,
pub modifiers: egui::Modifiers,
}
#[derive(Debug, Clone)]
pub struct ThemeCustomization {
pub colors: FxHashMap<String, egui::Color32>,
}