Skip to main content

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    REPOS_SKELETON_CONTENT, ensure_settings_keys_present, ensure_theme_keys_present,
27    maybe_migrate_legacy_confs, save_app_start_mode, save_fuzzy_search, save_mirror_count,
28    save_news_filter_installed_only, save_news_filter_show_advisories,
29    save_news_filter_show_arch_news, save_news_filter_show_aur_comments,
30    save_news_filter_show_aur_updates, save_news_filter_show_pkg_updates,
31    save_news_filters_collapsed, save_news_max_age_days, save_results_filter_show_canonical,
32    save_scan_do_clamav, save_scan_do_custom, save_scan_do_semgrep, save_scan_do_shellcheck,
33    save_scan_do_sleuth, save_scan_do_trivy, save_scan_do_virustotal, save_selected_countries,
34    save_show_install_pane, save_show_keybinds_footer, save_show_recent_pane, save_sort_mode,
35    save_startup_news_configured, save_startup_news_max_age_days,
36    save_startup_news_show_advisories, save_startup_news_show_arch_news,
37    save_startup_news_show_aur_comments, save_startup_news_show_aur_updates,
38    save_startup_news_show_pkg_updates, save_virustotal_api_key,
39};
40pub use paths::{config_dir, lists_dir, logs_dir, resolve_repos_config_path};
41pub use settings::settings;
42pub use store::{reload_theme, theme};
43pub use types::{KeyChord, KeyMap, PackageMarker, Settings, Theme};
44
45#[cfg(test)]
46static TEST_MUTEX: std::sync::OnceLock<std::sync::Mutex<()>> = std::sync::OnceLock::new();
47
48#[cfg(test)]
49/// What: Provide a process-wide mutex to serialize filesystem-mutating tests in this module.
50///
51/// Inputs:
52/// - None
53///
54/// Output:
55/// - Shared reference to a lazily-initialized `Mutex<()>`.
56///
57/// Details:
58/// - Uses `OnceLock` to ensure the mutex is constructed exactly once per process.
59/// - Callers should lock the mutex to guard environment-variable or disk state changes.
60pub(crate) fn test_mutex() -> &'static std::sync::Mutex<()> {
61    TEST_MUTEX.get_or_init(|| std::sync::Mutex::new(()))
62}