use crossterm::event::{KeyCode, KeyModifiers}; mod io; mod keybinds; mod model; mod sound; mod theme; pub use self::{ io::{ config_dir, config_path, load_live_keybinds, remove_section_key, upsert_section_bool, upsert_section_value, }, keybinds::{ format_key_combo, CommandKeybindConfig, CustomCommandAction, CustomCommandKeybind, Keybinds, LiveKeybindConfig, }, model::{Config, ToastConfig, ToastDelivery}, sound::{AgentSoundSetting, SoundConfig}, theme::{parse_color, CustomThemeColors, ThemeConfig}, }; pub(crate) use self::io::upsert_top_level_bool; pub const CONFIG_PATH_ENV_VAR: &str = "HERDR_CONFIG_PATH"; pub const DEFAULT_SCROLLBACK_LIMIT_BYTES: usize = 10_000_000; #[cfg(test)] pub(crate) fn app_dir_name() -> &'static str { io::app_dir_name() } impl Config { pub fn should_show_onboarding(&self) -> bool { self.onboarding.unwrap_or(true) } pub fn prefix_key(&self) -> (KeyCode, KeyModifiers) { self.validated_keybinds().1 } /// Parsed keybinds for navigate mode actions. pub fn keybinds(&self) -> Keybinds { self.validated_keybinds().3 } pub fn collect_diagnostics(&self) -> Vec { let (prefix_diag, _, keybind_diags, _) = self.validated_keybinds(); prefix_diag .into_iter() .chain(keybind_diags) .chain(self.ui.sound.diagnostics()) .collect() } pub fn live_keybinds(&self) -> Result> { let (prefix_diag, prefix, keybind_diags, keybinds) = self.validated_keybinds(); let diagnostics: Vec = prefix_diag.into_iter().chain(keybind_diags).collect(); if diagnostics.is_empty() { Ok(LiveKeybindConfig { prefix, keybinds }) } else { Err(diagnostics) } } }