pacsea/theme/
mod.rs

1//! Theme system for Pacsea.
2//!
3//! Split from a monolithic file into submodules for maintainability. Public
4//! re-exports keep the `crate::theme::*` API stable.
5
6/// Configuration file management and migration.
7mod config;
8/// Configuration parsing utilities.
9mod parsing;
10/// Path resolution for config directories.
11mod paths;
12/// Unified theme resolution logic.
13mod resolve;
14/// Settings access and management.
15mod settings;
16/// Theme store and caching.
17mod store;
18/// Terminal detection for theme fallback.
19mod terminal_detect;
20/// Terminal color query and theme derivation.
21mod terminal_query;
22/// Theme type definitions.
23mod types;
24
25pub use config::{
26    ensure_settings_keys_present, maybe_migrate_legacy_confs, save_app_start_mode,
27    save_fuzzy_search, save_mirror_count, save_news_filter_installed_only,
28    save_news_filter_show_advisories, save_news_filter_show_arch_news,
29    save_news_filter_show_aur_comments, save_news_filter_show_aur_updates,
30    save_news_filter_show_pkg_updates, save_news_filters_collapsed, save_news_max_age_days,
31    save_scan_do_clamav, save_scan_do_custom, save_scan_do_semgrep, save_scan_do_shellcheck,
32    save_scan_do_sleuth, save_scan_do_trivy, save_scan_do_virustotal, save_selected_countries,
33    save_show_install_pane, save_show_keybinds_footer, save_show_recent_pane, save_sort_mode,
34    save_startup_news_configured, save_startup_news_max_age_days,
35    save_startup_news_show_advisories, save_startup_news_show_arch_news,
36    save_startup_news_show_aur_comments, save_startup_news_show_aur_updates,
37    save_startup_news_show_pkg_updates, save_virustotal_api_key,
38};
39pub use paths::{config_dir, lists_dir, logs_dir};
40pub use settings::settings;
41pub use store::{reload_theme, theme};
42pub use types::{KeyChord, KeyMap, PackageMarker, Settings, Theme};
43
44#[cfg(test)]
45static TEST_MUTEX: std::sync::OnceLock<std::sync::Mutex<()>> = std::sync::OnceLock::new();
46
47#[cfg(test)]
48/// What: Provide a process-wide mutex to serialize filesystem-mutating tests in this module.
49///
50/// Inputs:
51/// - None
52///
53/// Output:
54/// - Shared reference to a lazily-initialized `Mutex<()>`.
55///
56/// Details:
57/// - Uses `OnceLock` to ensure the mutex is constructed exactly once per process.
58/// - Callers should lock the mutex to guard environment-variable or disk state changes.
59pub(crate) fn test_mutex() -> &'static std::sync::Mutex<()> {
60    TEST_MUTEX.get_or_init(|| std::sync::Mutex::new(()))
61}